-
Notifications
You must be signed in to change notification settings - Fork 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
fix: Handle SIGUSR1 even under +B i / +B d #4553
Conversation
This might be the fix behind the shell bugs we see with escripts and rebar3 when exiting the instance. |
Shell bug? |
I opened it as https://bugs.erlang.org/browse/ERL-1162 and it was closed as a duplicate. When starting
However, when the
I've attached the broken output as an image: This problem is made a bit worse because escripts mandate the |
Ah, that good oldie. I've linked in all the info in the github issue tracking this. |
Not restoring terminal state on Ctrl-C with +B d is related, but not identical, to this problem and the one described in #3150. This commit handles SIGUSR1 only; for +B d, we would want to handle SIGINT with a handler to run (at least) the tty cleanup code in |
I can confirm that this change does not fix garbled terminal after exiting |
Gentle ping: any objection to merging this? I'm having a hard time envisioning a system that depends on SIGUSR1 hard-killing BEAM (note that any action by user code to change handling of SIGUSR1, in particular any call to |
Currently a bit short on time. Will have a look at it at the end of the week. |
Short version: I'm for this, but into the SIGUSR1 has always (at least since the 90ies) been lumped together with SIGINT and SIGQUIT in the "break handling" and restored to their default actions if +B (or +Bd) was passed as argument at startup. I don't see what SIGUSR1 has to do with "break handlng", though. I guess that someone wanted a way to restore all signal actions to their defaults that could be restored to their defaults without breaking the system. +Bi was introduced in order to prevent key combinations (Ctrl-C, Ctrl-\, Ctrl-Z causing signals being sent to the emulator) resulting in the emulator being suspended, halted, etc. The SIGUSR1 probably by mistake got set to default action, when +Bi is passed, just because it had always been lumped together with SIGINT and SIGQUIT in the initialization of "break handling". I don't see any reason why the behavior of SIGUSR1 should change when +Bi is passed. I don't think we should introduce this change in OTP 23 since it changes a behavior that has been there for a very long time, but I think we should change it in OTP 24 since current behavior makes no sense. |
The OTP documentation states that SIGUSR1 causes a crash dump unconditionally. However, under +B i or +B d, the call to install the SIGUSR1 handler was not made before this change, causing SIGUSR1 to kill process immediately instead.
With this change to the test but not the fix in the previous commit, running os_signal_SUITE with emulator arg +Bd or +Bi will fail (BEAM will die with a signal, which is not the best way to fail a test, but we don't have a shell test suite to catch it). To confirm, you can use ts, with `ts:run(emulator, os_signal_SUITE, [{vars, [{erl_start_args, "+Bd"}]}]).`.
Thanks for the review! Rebased onto master. |
The OTP documentation states that SIGUSR1 causes a crash dump unconditionally.
However, under +B i or +B d, the call to install the SIGUSR1 handler was not
made before this change, causing SIGUSR1 to kill process immediately instead.
Fixes #4552.