Skip to content

Add System.IO.Signals.Unix #15178

Closed
Closed

Description

@Petermarcu

Signals are a ubiquitous mechanism across Unix systems for interactions between processes and the kernel. The only API we currently have for sending any signal is Process.Kill(), which sends a SIGKILL signal, but to write robust Unix applications (and services) you likely want to be able to both send signals and handle specific signals. The former can be done by a dev using a P/Invoke, but the latter would really require libcoreclr support to do correctly, especially since the runtime itself already hooks certain signals (e.g. a SIGINT signal sent by ctrl-C, which we then subscribe to the runtime for in Console.CancelEventHandler).

Activity

  1. assigned and unassigned on Nov 12, 2015
  2. stephentoub commented on Apr 18, 2016

    @stephentoub
    Member

    does this need dotnet/coreclr#2688 to be finished first?

    No, it shouldn't.

  3. karelz commented on Oct 11, 2016

    @karelz
    Member

    We need API proposal

  4. chadwackerman commented on Jan 3, 2017

    @chadwackerman

    Does "We need API proposal" actually count as managing this issue? (Are you really managing one of the largest and most out of control projects at Microsoft using GitHub tags @karelz? Folksonomy doesn't even scale to the average knitting blog.)

    Isn't this just a couple of event handlers? Where do you want to put the non-obvious ones?

    AssemblyLoadContext.Default.Unloading += MethodInvokedOnSigTerm; // an obvious one
    
  5. karelz commented on Jan 3, 2017

    @karelz
    Member

    @chadwackerman I am not sure what exactly is your question here.
    Yes, we are using GitHub tags for categorizing issues -- here's more details about it.
    The comment "We need API proposal" is meant to suggest the next step (see details here).

    You can learn more about formal API proposals.

    All docs should be linked from project root.

    Isn't this just a couple of event handlers?

    Possibly, that's exactly what we expect from API proposal - someone to think deeply about it and propose API with story about it (why, how, what, rejected alternatives, etc.).

    Please let's stay technical (see contributor code of conduct).

  6. chadwackerman commented on Jan 3, 2017

    @chadwackerman

    Is there a tag link I can click on that shows items waiting for an API proposal? I don't see one here. And are you seriously (and silently!) asking the community to map signal.h to an enum and delegates?

    Microsoft already owns shipping code that does this. It's called Mono.

    You can click the linked issues around Unix signals in this GitHub project and it takes you in a circle, with nobody doing anything. You can actually use the PowerBI GitHub adaptor to show that Microsoft employees are (I hope unconsciously!) blocking on one another. It's almost as bad as those Microsoft Support sites where three Microsoft subcontractors upvote each other's wrong answers. (But hey, the time to close metrics sure look great!)

    With all due respect I think the process here is failing you. Somebody needs to take ownership of an issue, not just tag and link to other issues.

    Meanwhile...

    I'm running a service on Azure Batch and it actually returns "success" from a cloud batch job if the exit code is nonzero. Why? Because Robocopy sometimes returns a 1 to indicate success.

    I'm trying to use the OneDriveSDK and the devs there swear it works cross platform and close issues. But it has dependencies on WinForms and STAThread so it doesn't even work in IIS let alone the command line on Linux.

    Either you're gonna support Linux or not. Perhaps starting with signal.h and honoring 0=success as a return code from main is a good start? .NET already whiffed on arg[0] being the name of the app, but maybe we can slowly turn this boat around. But I don't believe the solution is a few more captains and a lot more tagging.

  7. karelz commented on Jan 3, 2017

    @karelz
    Member

    Is there a tag link I can click on that shows items waiting for an API proposal?

    All api-needs-work items are API additions which are not api-approved and not api-ready-for-review (see API review process)

    ... are you seriously (and silently!) asking the community to map signal.h to an enum and delegates?

    We are seriously (and loudly!) asking anyone who will grab this issue to provide a proposal -- it may be MS employee or it may be community member, we are treating people equally in this matter. If it is a simple mapping of signal.h, then be it. Maybe it is more complicated. (I don't know, because I didn't look deeper into the issue - that's what the person grabbing it is supposed to do)

    Microsoft already owns shipping code that does this. It's called Mono.

    Leveraging Mono code/design is very reasonable approach. We also do it where it helps. Whoever gets to work on this one first is free to consider it.

    You can click the linked issues around Unix signals in this GitHub project and it takes you in a circle, with nobody doing anything.

    I am not sure which link-circles you refer to, but even the Milestone set to Future on this issue is supposed to set the expectation that CoreFX team does not consider it as something must-have for next version (2.0), so the "nobody doing anything" is expected at least from MS employees. If community members believe we are misjudging the priority, we encourage them to either contribute or help us understand the impact of the issue better (in a constructive polite way please).

    You can actually use the PowerBI GitHub adaptor to show that Microsoft employees are (I hope unconsciously!) blocking on one another.

    Never tried PowerBI adaptor. I am not sure how it would help us.
    This particular issue is blocked only by "resources" (i.e. someone doing the job).
    In general, I think I have high-level insight into most of the repo issues and areas and I am pretty sure there is very nearly zero issues where MS employees are blocked on one another in CoreFX repo.

    @chadwackerman maybe it will be a surprise to you, but we (CoreFX teams) are not bunch of lazy or ignorant engineers. We are trying to do the right things the right way. I can't force you to believe that, but I will at least ask you to be constructive and technical in your criticism -- we are open to arguments and discussions. Throwing in general statements and unfounded accusations is not going to help anyone (and I plan to stop responding to them, potentially start deleting them).

    On the other hand, if someone truly wants to understand the motivation for our process or repo organization, I'll be very happy to explain (and eventually adjust docs to capture it). We are also open to feedback on the process/docs, especially if it is feedback supported by larger part of our community.

    Somebody needs to take ownership of an issue, not just tag and link to other issues.

    Until the issue is assigned to someone it does not have an "owner". The area experts help watch over all issues in their areas and help identify bugs which might have been incorrectly prioritized or where new information arises from the discussion.
    This particular issue has 7 votes so far and does not have any evidence that the missing API is blocking major work on .NET Core. If you believe this is wrong assessment, you have 2 options: Convince us (with evidence and motivation) that it is higher importance, or contribute.

    I'm running a service on Azure Batch and it actually returns "success" from a cloud batch job if the exit code is nonzero. Why? Because Robocopy sometimes returns a 1 to indicate success.

    I don't see how it is related to this issue.

    I'm trying to use the OneDriveSDK and the devs there swear it works cross platform and close issues. But it has dependencies on WinForms and STAThread so it doesn't even work in IIS let alone the command line on Linux.

    Please work with their team. CoreFX is not the right place to raise that issue.

    Either you're gonna support Linux or not. Perhaps starting with signal.h and honoring 0=success as a return code from main is a good start?

    I fail to see how it is relevant to this issue. If you think there is a bug in .NET Core apps returning non-0 value by default, please file it as separate issues and let it be discussed on its own. Let's not entangle issues together please, unless they are truly relevant e.g. in overall end-to-end impact.

  8. soyeyalon commented on Jan 3, 2017

    @soyeyalon

    @chadwackerman If you want to give them feedback about their process or file a bug you can always open a new issue about it but please don't derail the issue at hand.

    p.s. Just a piece of friendly advice, you can lose the attitude, no one awe you anything.

  9. chadwackerman commented on Jan 3, 2017

    @chadwackerman

    @eyalsk This isn't a hobbyist's blog engine, this is a core technology from a company worth nearly half a trillion dollars. They're charging me by the minute to run my Linux dotnet apps and they very much do owe me something.

    Among the other candy-colored rectangles I see "up for grabs" and "backlog" but "only 7 votes" and "not expected for v2.0." Meanwhile there's many related bugs and lots of StackOverflow traffic when you Google the issue, which is how I landed here. Apparently I need to build a political action committee or hire lobbyists since we're voting on technology now?

    We have a senior Microsoft manager who chimes in with "We need API proposal" - end of sentence, no punctuation. The unintentional effect of which is Cookie Licking as it appears the true answer is "Yes, we are expecting the community to solve signal.h despite everyone from Satya down to Scott Hanselman saying we're all aboard the Linux train."

    I don't see how it is related to this issue.

    There's a LOT of really amateurish stuff going on at the command line with the various Microsoft teams and it doesn't surprise me that nobody is jumping in to tackle this issue. "return 0" means success, stop hooking my app's signals with your wonky libraries without letting me override, and maybe cut down on the verbosity of the compilers because what it spits out reads like second year college projects where you can feel the youthful excitement seeping out of the passively-voiced text:

    "Project will be compiled because inputs were modified... Project will be compiled because expected outputs are missing... Time elapsed 00:00:02.2927068"

    I realize .NET format strings are confusing but sheesh, this ain't the Carnegie Mellon University Pascal compiler lab circa 1990 fellas.

  10. soyeyalon commented on Jan 4, 2017

    @soyeyalon

    @chadwackerman

    This isn't a hobbyist's blog engine, this is a core technology from a company worth nearly half a trillion dollars. They're charging me by the minute to run my Linux dotnet apps and they very much do owe me something.

    Can you create a new issue about your problem?

    Among the other candy-colored rectangles I see "up for grabs" and "backlog" but "only 7 votes" and "not expected for v2.0." Meanwhile there's many related bugs and lots of StackOverflow traffic when you Google the issue, which is how I landed here. Apparently I need to build a political action committee or hire lobbyists since we're voting on technology now?

    Can you create a new issue about it? i.e. giving them feedback about their process.

    There's a LOT of really amateurish stuff going on at the command line

    Can you create a new issue about it?

    with the various Microsoft teams and it doesn't surprise me that nobody is jumping in to tackle this issue. "return 0" means success,

    Same as above.

    stop hooking my app's signals with your wonky libraries without letting me override,

    Same as above

    and maybe cut down on the verbosity of the compilers

    Same as above.

    I'm sure they will want to know about the problems you're having.

  11. chadwackerman commented on Jan 4, 2017

    @chadwackerman

    @eyalsk I'm sure you're the first guy to grab the Scrabble box for rules clarifications. Unfortunately adding another five tiny issues to the massive backlog here is unlikely to move the needle. Which if you'll take a few minutes away from your busy schedule spent starring repositories for no reason, you may realize indicates a bigger problem with the process here. Thus my raising the issue the way I did.

    We're dealing with serious technical issues by clicking TiVo thumbs up/down buttons and there's a grown man who works at Microsoft getting stock awards for taking it seriously and parroting four word responses back to us. Moreover there is no sane path to discuss strategic issues which pushes all this toward the inevitable marketing and social circlejerk. Seriously--write a bot to crawl these issues links and they all point to each other, all stuck on each other. We're watching Vista unfold in real time here.

    Sure, I can email a few buddies and get this bumped from 7 to 20 upvotes. Meanwhile there's critical stuff with thousands of votes ignored for years so what's the point? I'm not sure what personality type is motivated to dive into this particular flavor of open source mess, but just as soon as @karelz finds a few minutes to tinker with the GitHub to Microsoft BI adaptor I'm sure he'll post a few numbers in support of his favorite bugs.

    And I were going to donate my time, I can think of a few thousand organizations more needy than the corporation that has the most cash on hand of any entity on Earth. But that's just me.

  12. 38 remaining items

  13. deinok commented on Feb 14, 2018

    @deinok

    @karelz Yes, Mono.Posix match the requirements, only asking if the intention of creating System.Posix.Signal is in development or if I can start an implementation for a future PR.

  14. eerhardt commented on Feb 14, 2018

    @eerhardt
    Member

    or if I can start an implementation for a future PR.

    I wouldn't get too far into an implementation without getting an API at least proposed and on the way to getting approved. Since getting it to an approved state may drastically change the implementation. So I'd suggest just doing prototyping to get to a place to have a proposed API. See https://github.com/dotnet/corefx/blob/master/Documentation/project-docs/api-review-process.md for the process.

    Also, along with proposing a new API, I'd consider what are the advantages of a new API over the existing APIs in Mono.Posix. And alternatively, if the additions could be made to Mono.Posix instead, which would benefit both Mono and .NET Core at the same time.

    My understanding of the current plan is to not duplicate APIs in Mono.Posix just so they are in the System namespace. There needs to be advantages over the existing APIs.

  15. deinok commented on Feb 15, 2018

    @deinok

    @eerhardt If the solution is not implement this in favour of Mono.Posix i think that we can close this.
    If not, I think that as a starting point we can map everything on C/POSIX signal.h with P/Invokes and give a more high level API with events like Signal.OnSigInt

  16. eerhardt commented on Feb 15, 2018

    @eerhardt
    Member

    It would be my preference to close this as well. I haven't seen any real-world scenarios that aren't supported by the Mono.Posix APIs, and that would justify creating a brand new, competing API. I'm sure Mono would accept PRs to enhance the existing APIs, if necessary.

    Anyone else have opinions?

  17. tmds commented on Feb 15, 2018

    @tmds
    Member

    Also in favor of closing. Mono.Posix should be good for generic handling/sending signals.
    Perhaps if there are specific use-cases that match closely with .NET Core, it may be interesting to add better support for those.

    Overview of what is currently possible using .NET Core:

    • handling SIGTERM: AssemblyLoadContext.Default.Unloading
    • handling SIGINT/SIGQUIT: Console.CancelKeyPress
    • sending SIGKILL: Process.Kill
  18. eerhardt commented on Feb 16, 2018

    @eerhardt
    Member

    Closing in favor of the existing specialized APIs shown directly above by @tmds and for general signal sending and handling with https://www.nuget.org/packages/Mono.Posix.NETStandard/.

    For signal handling, you have 2 options:

    1. Use Stdlib.SetSignalAction - to set which action should be performed when the signal is raised. The options are either the default (SIG_DFL), error (SIG_ERR), or ignore (SIG_IGN) handlers.
    2. Use UnixSignal to respond to a raised signal:
    	var sigintRaised = new UnixSignal(Signum.SIGINT);
    	while (sigintRaised.WaitOne()) {
    		Console.WriteLine(“Control-C pressed!”);
    	}

    Note that it blocks the thread until the signal is raised. See http://docs.go-mono.com/?link=T%3aMono.Unix.UnixSignal for docs.

  19. admilazz commented on May 2, 2019

    @admilazz

    Mono.Posix doesn't let you send a signal to a process given its process ID. It is, therefore, pretty useless for the purpose of this issue.

  20. transferred this issue fromdotnet/corefxon Jan 31, 2020
  21. added this to the 2.1.0 milestone on Jan 31, 2020
  22. shravan2x commented on Mar 23, 2020

    @shravan2x

    @eerhardt @tmds @karelz @danmosemsft I have the same concern as @admilazz that Mono.Posix doesn't support sending signals given a process' PID. If we're mistaken and just missing the documentation for it, please point us there.

    Maybe it would be Syscall.kill?

    If not, can we re-open this issue?

  23. karelz commented on Mar 23, 2020

    @karelz
    Member

    We should not reopen issues which are closed for 2 years. Our plan is to actually lock closed issues after few weeks of being closed and without comments.
    If there are enhancement suggestions on top of current plan / implementation, please file them as new issues. Thanks.

  24. eerhardt commented on Mar 23, 2020

    @eerhardt
    Member

    Mono.Posix doesn't support sending signals given a process' PID

    @shravan2x - does the following help?

    https://stackoverflow.com/a/35809358/3680432

  25. shravan2x commented on Mar 23, 2020

    @shravan2x

    @eerhardt From your link, it seems to be Syscall.kill as I suspected (I'd assumed that SIGCONT couldn't be sent from a command named kill, my bad). Glad to leave an answer here for anyone else that needs it. Thanks!

  26. ghost locked as resolved and limited conversation to collaborators on Jan 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    api-needs-workarea-System.IOhelp wantedos-linux

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions