improvement(core): handle more OS signals and broadcast them#2667
Conversation
Signed-off-by: Onur Özkan <work@onurozkan.dev>
Signed-off-by: Onur Özkan <work@onurozkan.dev>
Signed-off-by: Onur Özkan <work@onurozkan.dev>
91215bb to
266d048
Compare
1063bea to
fac42f6
Compare
|
There is a new feature since your approval. @dimxy |
Signed-off-by: Onur Özkan <work@onurozkan.dev>
fac42f6 to
4c2b8a3
Compare
mariocynicys
left a comment
There was a problem hiding this comment.
thanks, all comments below are nits.
LGTM!
| let signal_name = match signal { | ||
| libc::SIGINT => "SIGINT".to_owned(), | ||
| libc::SIGTERM => "SIGTERM".to_owned(), | ||
| libc::SIGQUIT => "SIGQUIT".to_owned(), | ||
| _ => format!("UNKNOWN({signal})"), | ||
| }; |
There was a problem hiding this comment.
since we intend to handle any signal, shouldn't we init our signal hook with all signals (if there is a catch all thing).
not really a problem since we have the important signals covered, but looking at this, the unknown signal line would never be triggered (though i would prefer it like that instead of unreachable! so i don't have a problem with that either).
There was a problem hiding this comment.
since we intend to handle any signal
No, not any signal. We can't handle every signal (e.g., we can't handle SIGKILL). I wanted to handle ones (the obvious ones) that can be handled.
|
@onur-ozkan thanks for this! It will make a significant difference in the GUI needing to poll to get wallet status.
I'm assuming your streaming event was intended as a QoL addition to the existing PR, initially fixing an iOS-specific issue, but it is worth adding the catching to Windows as well. We won't encounter the file descriptor limit issue on non-iOS platforms, but there may be other reasons KDF shuts down via a signal. e.g. user terminates the KDF process in the task manager. |
Yeah, we should support Windows too but it would require a broader work. We can handle that later (I guess when it becomes very necessary?). |
2a6bf9a to
a35426f
Compare
Makes KDF to broadcast (through streaming manager) OS signal before the graceful shutdown.
Also, refactors the
spawn_ctrl_c_handlerfunction to cover more signals in a more generic way (can handle more signals easily when needed).The event activation RPC:
The broadcasted message:
for the signals we can't gracefully shutdown, the message will be "UNKNOWN($id_of_the_signal)".
This feature isn't supported on Windows, and doesn't run on Web for obvious reasons.