-
Notifications
You must be signed in to change notification settings - Fork 17.3k
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
runtime/cgo: allow external library to register its own signal handler? #4216
Labels
Comments
this issue is difficult to fix. libreadline registered a signal handler of its own. however, when the signal comes, it runs on Go's segmented stack, and it will surely crash. one possible solution is that we export our own sigaction and signal and override libc version of these two functions so that we can use cgo bridge to call that signal handler on C stack. |
Yes I can disable readline's signal handling and do the processing manually. Also, readline provides e.g. cleanup functions I can call to process SIGINT correctly, in particular to restore the terminal attributes. It might take a bit more work to have the readline() call return to the caller in Go (while in C doing fclose(stdin) is enough). Also, from the perspective of a readline binding package, it would be nice to emulate the default readline behavior of catching SIGINT, doing the cleanup and resending the signal. However this would require support from the os/signal package to temporarily remove existing SIGINT handlers (with the current API one can only add a handler, which results in a race condition if another SIGINT handler calls os.Exit() before cleanup is done). |
Issue #5287 has been merged into this issue. |
> Go's signal handlers must not be overridden. I don't see any way around this. As this has come up yet again via issue #7227, I have to question this. Why not use kqueue with signal filters on the BSDs and use signalfd() on Linux? That'd allow Go to receive the signals no matter what the handler happen to be set to by 3rdparties. |
This issue was closed.
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
The text was updated successfully, but these errors were encountered: