-
Notifications
You must be signed in to change notification settings - Fork 129
fix InterruptHandler to be safer #249
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
Conversation
motivation: InterruptHandler can crash when signal is handled by globals are not initialized changes: * mark InterruptHandler as deprecated since DispatchSource provides this functionality already * change InterruptHandler globals to static members * add code to ensure the static state is initialized to make it more signal safe
thanks @CodaFi for diagnosing this |
@swift-ci please test |
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.
Thank you!
/// This class can be used by command line tools to install a handler which | ||
/// should be called when a interrupt signal is delivered to the process. | ||
@available(*, deprecated, message: "use DispatchSource instead") |
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.
🎊
#if os(Windows) | ||
private static var signalWatchingPipe: [HANDLE] = [INVALID_HANDLE_VALUE, INVALID_HANDLE_VALUE] | ||
#else | ||
private static var signalWatchingPipe: [Int32] = [0, 0] |
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.
Probably better to use a tuple for this one and the windows one but meh that's really not important.
This breaks the windows build :-( |
motivation: InterruptHandler can crash when signal is handled but globals are not initialized
changes:
rdar://76272674