-
Notifications
You must be signed in to change notification settings - Fork 6
Description
Normally, SID daemon reacts to SIGTERM and it shuts itself down gracefully upon reception of this signal. However, if SID daemon forks at least one worker process (and that one can finish completely), the signal handler is not working correctly further - there's no reaction, the signal handler is not called at all.
This seems to be related to the code in worker_control_get_new_worker where a new worker process is forked from daemon. After forking, in the worker process, we separate several resources we also need in the worker and we attach all of these inherited resources to top-level "worker" resource we've just created. Then we destroy the rest of unneeded resources in the worker process, including the "sid" resource which had SIGTERM and SIGINT signals registered (and which was previously the top-level resource).
Above-mentioned sequence is executed in worker-control code right here:
All works as expected (SIGTERM signal handling is OK) after commenting out this line: https://github.com/sid-project/sid-mvp/blob/0cd4698aa6d94d4b59cdbb892c689632d8572759/src/resource/worker-control.c#L142
It looks that registering and then deregistering signal handlers (even though for various event loops) get messed up somehow...
Obviously, this is an issue when we're trying to stop SID daemon (...if that's systemctl stop sid.service, then the systemctl call halts because it is unable to stop the service - that will never stop as the signal is not processed).