-
Notifications
You must be signed in to change notification settings - Fork 4.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement PosixSignal API #54136
Implement PosixSignal API #54136
Conversation
Note regarding the This serves as a reminder for when your PR is modifying a ref *.cs file and adding/modifying public APIs, to please make sure the API implementation in the src *.cs file is documented with triple slash comments, so the PR reviewers can sign off that change. |
@@ -775,6 +775,26 @@ public sealed partial class OptionalAttribute : System.Attribute | |||
{ | |||
public OptionalAttribute() { } | |||
} | |||
public enum PosixSignal |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've manually added these to the ref
file, I don't know if there is an automated way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The automated way is documented in https://github.com/dotnet/runtime/blob/main/docs/coding-guidelines/updating-ref-source.md . It would be a good idea to rerun the automated process to make sure that the formatting is right.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But beware, it currently removes attributes...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I ran it and copied in the PosixSignal
bits.
I'm surprised to see internal
instead of private
on the PosixSignalRegistration
constructor.
src/libraries/System.Runtime.InteropServices/src/System.Runtime.InteropServices.csproj
Outdated
Show resolved
Hide resolved
src/libraries/System.Runtime.InteropServices/src/System.Runtime.InteropServices.csproj
Outdated
Show resolved
Hide resolved
...ries/System.Runtime.InteropServices/src/System/Runtime/InteropServices/PosixSignalContext.cs
Outdated
Show resolved
Hide resolved
...m.Runtime.InteropServices/src/System/Runtime/InteropServices/PosixSignalRegistration.Unix.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Runtime.InteropServices/src/System/Runtime/InteropServices/PosixSignal.cs
Show resolved
Hide resolved
...m.Runtime.InteropServices/src/System/Runtime/InteropServices/PosixSignalRegistration.Unix.cs
Outdated
Show resolved
Hide resolved
...System.Runtime.InteropServices/src/System/Runtime/InteropServices/PosixSignalRegistration.cs
Outdated
Show resolved
Hide resolved
...m.Runtime.InteropServices/src/System/Runtime/InteropServices/PosixSignalRegistration.Unix.cs
Outdated
Show resolved
Hide resolved
...m.Runtime.InteropServices/src/System/Runtime/InteropServices/PosixSignalRegistration.Unix.cs
Outdated
Show resolved
Hide resolved
...m.Runtime.InteropServices/src/System/Runtime/InteropServices/PosixSignalRegistration.Unix.cs
Outdated
Show resolved
Hide resolved
src/libraries/Common/src/Interop/Unix/System.Native/Interop.PosixSignal.cs
Show resolved
Hide resolved
...m.Runtime.InteropServices/src/System/Runtime/InteropServices/PosixSignalRegistration.Unix.cs
Show resolved
Hide resolved
...m.Runtime.InteropServices/src/System/Runtime/InteropServices/PosixSignalRegistration.Unix.cs
Outdated
Show resolved
Hide resolved
...m.Runtime.InteropServices/src/System/Runtime/InteropServices/PosixSignalRegistration.Unix.cs
Outdated
Show resolved
Hide resolved
...System.Runtime.InteropServices/src/System/Runtime/InteropServices/PosixSignalRegistration.cs
Outdated
Show resolved
Hide resolved
...m.Runtime.InteropServices/src/System/Runtime/InteropServices/PosixSignalRegistration.Unix.cs
Outdated
Show resolved
Hide resolved
...m.Runtime.InteropServices/src/System/Runtime/InteropServices/PosixSignalRegistration.Unix.cs
Show resolved
Hide resolved
...m.Runtime.InteropServices/src/System/Runtime/InteropServices/PosixSignalRegistration.Unix.cs
Outdated
Show resolved
Hide resolved
Hey, I just wanted to drop by and say it's really exciting to see this work! 🥳 |
...m.Runtime.InteropServices/src/System/Runtime/InteropServices/PosixSignalRegistration.Unix.cs
Outdated
Show resolved
Hide resolved
src/libraries/Common/src/Interop/Unix/System.Native/Interop.PosixSignal.cs
Outdated
Show resolved
Hide resolved
src/libraries/Common/src/Interop/Unix/System.Native/Interop.PosixSignal.cs
Show resolved
Hide resolved
The implementation has changed a bit since the initial PR.
The implementation will call the original It handles specifically what is cancelable by the runtime using
I'll look at writing some tests next week. |
Just posting here as well so it doesn't get missed: I think it's worth considering a rename to |
...m.Runtime.InteropServices/src/System/Runtime/InteropServices/PosixSignalRegistration.Unix.cs
Outdated
Show resolved
Hide resolved
@tmds what's the expected behavior if users set up a handler for a signal that the runtime uses internally. For example, the mono GC uses signals on non-Apple Unixes to suspend threads that are in preemptive mode - we pick the signal dynamically and use runtime/src/mono/mono/utils/mono-threads-posix-signals.c Lines 48 to 119 in f37f0b9
Should we have some mechanism that the runtime could use to prevent users from installing handlers for these signals? |
...m.Runtime.InteropServices/src/System/Runtime/InteropServices/PosixSignalRegistration.Unix.cs
Outdated
Show resolved
Hide resolved
...m.Runtime.InteropServices/src/System/Runtime/InteropServices/PosixSignalRegistration.Unix.cs
Outdated
Show resolved
Hide resolved
...m.Runtime.InteropServices/src/System/Runtime/InteropServices/PosixSignalRegistration.Unix.cs
Outdated
Show resolved
Hide resolved
...m.Runtime.InteropServices/src/System/Runtime/InteropServices/PosixSignalRegistration.Unix.cs
Outdated
Show resolved
Hide resolved
...m.Runtime.InteropServices/src/System/Runtime/InteropServices/PosixSignalRegistration.Unix.cs
Outdated
Show resolved
Hide resolved
...m.Runtime.InteropServices/src/System/Runtime/InteropServices/PosixSignalRegistration.Unix.cs
Outdated
Show resolved
Hide resolved
...m.Runtime.InteropServices/src/System/Runtime/InteropServices/PosixSignalRegistration.Unix.cs
Outdated
Show resolved
Hide resolved
...m.Runtime.InteropServices/src/System/Runtime/InteropServices/PosixSignalRegistration.Unix.cs
Outdated
Show resolved
Hide resolved
Co-authored-by: Stephen Toub <stoub@microsoft.com>
…anceledPosixSignal.
CI fail is unrelated. |
...ries/System.Runtime.InteropServices/src/System/Runtime/InteropServices/PosixSignalContext.cs
Outdated
Show resolved
Hide resolved
...ries/System.Runtime.InteropServices/src/System/Runtime/InteropServices/PosixSignalContext.cs
Show resolved
Hide resolved
Co-authored-by: Stephen Toub <stoub@microsoft.com>
Thanks! |
Implements #50527.
I still need to add tests.
Can you do a first review of the implementation?
cc @janvorli @jkotas @stephentoub @davidfowl @bartonjs