aboutsummaryrefslogtreecommitdiff
path: root/initd/runsvc.c
AgeCommit message (Collapse)Author
2020-05-14Replace standard signal handling in initd with signalfd + epollDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <goliath@infraroot.at>
2020-05-14Move handling of dead children back to SIGCHLD handlerDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <goliath@infraroot.at>
2020-05-13Cleanup: Remove SIGCHLD handler from initdDavid Oberhollenzer
Instead use wait() in the main loop. This way, the supervisor functions (except set target) are no longer called from signal context and can be simplified a little. Signed-off-by: David Oberhollenzer <goliath@infraroot.at>
2020-05-13Add utility functions for clearing/setting signal maskDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <goliath@infraroot.at>
2020-05-13Fix runsvc waiting behaviour if run as subreaperDavid Oberhollenzer
It basically needs to wait for ALL children (even those created by child processes) to terminate before terminating itself. This commit replaces the waitpid loop with a regular wait that and adds another wait loop at the end of run_sequentially to wait for any transitive children. The sigchld handling is removed from the signal handler and the handler is only installed for SIGINT, SIGTERM and SIGHUP. The other signals that initd hooks are set to default. Signed-off-by: David Oberhollenzer <goliath@infraroot.at>
2020-05-09Install a propper signal handler in runsvcDavid Oberhollenzer
If runsvc is installed as sub reaper, it must handle SIGCHLD or the system will accumulate zombie processes. Also, forward all other signal to the currently supervised child process and hope that if it is SIGTERM, the child itself knows how to shut down any other processes it created. Signed-off-by: David Oberhollenzer <goliath@infraroot.at>
2020-05-08Implement a "subreaper" service flagDavid Oberhollenzer
For particularly hostile daemons. Signed-off-by: David Oberhollenzer <goliath@infraroot.at>
2020-05-06Do not close stdin/out/err file descriptors in runsvcDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <goliath@infraroot.at>
2020-04-24Add a fallback for close_all_files if procfs isn't mountedDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <goliath@infraroot.at>
2020-04-24cleanup: merge runsvc back into initdDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <goliath@infraroot.at>
2020-03-31cleanup: initd: simplify and merge linux specific code into main.cDavid Oberhollenzer
Targetting anything else than Linux isn't really relevant. All other systems ($BSD and other Unices) are a closed ecosystem where kernel & userspace are developed together. They don't need something like a third party init system, so compatibillity can be largely ignored. Signed-off-by: David Oberhollenzer <goliath@infraroot.at>
2018-11-23Relicense what is left of the init system under OpenBSD style ISC licenseDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@tele2.at>
2018-08-24initd: restructure and merge service supervision codeDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@tele2.at>
2018-04-22Add helper program for running servicesDavid Oberhollenzer
We no longer need to keep entire scripts in init program (i.e. saving space) and reduce the code and complexity of the init program. The runsvc tool can later be extended to do more complex child setup, such as configuring namespaces or seccomp without adding complexity or memory footprint to init. Signed-off-by: David Oberhollenzer <david.oberhollenzer@tele2.at>