Skip to content
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

Cleanup children in prefork mode, annotate NORETURN to fix implicit fallthrough #60

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

flu0r1ne
Copy link

This PR primarily addresses issue #19, although it tackles other issues as well. When the prefork option is specified via the command line, the initial process spawns a set number of child processes within a control loop. While there is a provision to reap these child processes upon their exit, the master process currently lacks a mechanism to notify them to terminate when it receives a SIGTERM or SIGINT. This behavior can be problematic due to variations in how different init systems and third-party managers handle program management. For example, systemd in its default configuration sends SIGTERM signals to all processes in the control group. However, this is not universally true; Docker, for instance, sends a SIGTERM only to the process specified in the ENTRYPOINT instruction.

Key Fixes and Improvements:

I'm up and running with these patches but have not tested this extensively. If maintainers consider merging this, I will follow up. I welcome community feedback.

With warnings and pedantic mode enabled, `gcc (GCC) 13.2.1` returns
an implicit fall through warning. This can be fixed by annotating
the error function with NORETURN.
Remove close as it always results in a duplicated call, simplify logic
When attached to a terminal, a SIGINT signal is sent to the parent
and all children, instructing them to exit. In some environments including
docker, only the parent receives the SIGTERM and is responsible for
propagating it to the children. This patch kills all child processes
when the parent receives a SIGTERM or a SIGINT.
@flu0r1ne
Copy link
Author

Oh, and it resolves #28

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant