aboutsummaryrefslogtreecommitdiff
path: root/initd
AgeCommit message (Collapse)Author
2020-06-15Minor cleanupHEADmasterDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <goliath@infraroot.at>
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-14Revert handling of wait type service to using stateDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <goliath@infraroot.at>
2020-05-14Cleanup: remove target completion hooksDavid Oberhollenzer
Simply make the service scripts handle accordingly. Signed-off-by: David Oberhollenzer <goliath@infraroot.at>
2020-05-14Minor cleanup: split initd main loop into smaller functionsDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <goliath@infraroot.at>
2020-05-14Move service rt data to libinit, try to improve memory packingDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <goliath@infraroot.at>
2020-05-14Cleanup: split print_status back out again from initd/main.cDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <goliath@infraroot.at>
2020-05-14Minor cleanupDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <goliath@infraroot.at>
2020-05-14initd: propperly handle error cases for wait()David Oberhollenzer
If we are interrupted by a signal, the target might have changed and we really, really have to return to the main loop. If wait failed because all children are dead, something went horribly wrong. There is NO POSSIBLE WAY to get out of this state and the best thing we can do is exit, to trigger a kernel panic. Signed-off-by: David Oberhollenzer <goliath@infraroot.at>
2020-05-14Partially restore old message printing behaviourDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <goliath@infraroot.at>
2020-05-14initd: split configuration handling into "config.c"David Oberhollenzer
This commit splits off only the handling of the service configuration and handling of the run time state and adds an abstraction layer in the form of functions that have to be called to access the data. Signed-off-by: David Oberhollenzer <goliath@infraroot.at>
2020-05-13initd: merge "handle exited" into "wait for a child process"David Oberhollenzer
Signed-off-by: David Oberhollenzer <goliath@infraroot.at>
2020-05-13Some simplfications in initd mainDavid Oberhollenzer
- Move the code of the supervisor main loop function into the main loop. - Remove the set target function and set the target variable directly in the signal handler. Signed-off-by: David Oberhollenzer <goliath@infraroot.at>
2020-05-13Move rest of initd supervisor code into main.cDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <goliath@infraroot.at>
2020-05-13Move the rest of the main loop into supervisor_process_queuesDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <goliath@infraroot.at>
2020-05-13Cleanup: Elimiate "waiting" state from supervisorDavid Oberhollenzer
Instead, use a wait() loop in the queue processing function. 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-09Fix accidental release of "waiting" stateDavid Oberhollenzer
If a singleshot service terminates, don't change the "waiting" sate. Signed-off-by: David Oberhollenzer <goliath@infraroot.at>
2020-05-09Minor simplifications/cleanupsDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <goliath@infraroot.at>
2020-05-08Simplify status printingDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <goliath@infraroot.at>
2020-05-08Cleanup: remove rest of status.cDavid Oberhollenzer
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-08Cleanup: complete redesign of the initd supervisorDavid Oberhollenzer
- Cleanly seperate service description parsed from file from the actual run-time data. - Remove the use of the signalfd and make asyncronous calls into the supervisor from signal context work. Signed-off-by: David Oberhollenzer <goliath@infraroot.at>
2020-05-07Temporarily remove initsock handling codeDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <goliath@infraroot.at>
2020-05-07Temporarily remove service reload abilityDavid Oberhollenzer
A cleaner, more planned out version will be added back later. 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: remove rdsvc flagsDavid Oberhollenzer
With the previous changes, there were only used by the status command. 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: delete remains of libutilDavid Oberhollenzer
- exec_t belongs to service.h, the main place where it is used/needed - code for executing exec_t is moved to runsvc for the same reason - what is left are NORETURN and ARRAY_SIZE - the former can be replaced with direct attribute usage since the only relevant compilers all support the attribute. - the later is only used in 3 places and can be trivially replaced with direct usage of sizeof(). 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>
2019-06-16Fix remove by idDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <goliath@infraroot.at>
2019-03-29fix: actually remove started service from listDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <goliath@infraroot.at>
2019-03-29Keep original respawn limitDavid Oberhollenzer
We also want this meachanism to still work for manually started service (especially after reloading services). Signed-off-by: David Oberhollenzer <goliath@infraroot.at>
2019-03-29cleanup: init socket wire formatDavid Oberhollenzer
Replace array adhockery with structs and make use of the handy endianness conversion macros. Signed-off-by: David Oberhollenzer <goliath@infraroot.at>
2019-03-29cleanup: move init specific stuff of init socket to initdDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <goliath@infraroot.at>
2019-03-29Add service configuration reloadingDavid Oberhollenzer
This commit add the ability to initd to reload the service configuration while running. The new configuration is merged with the existing one as follows: For each target: - If the existing service list is not NULL, we have not started that target yet. Simply replace it with the new list. - If it is NULL, the services have already been started. - First, remove all entries for services in that target that no loner exist (except from the 'running' list). - Second, add new services that we don't have yet. Treat them as recently diseased and let the user start them manualy. Signed-off-by: David Oberhollenzer <goliath@infraroot.at>
2019-03-28Add start/stop commands to init socketDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <goliath@infraroot.at>
2019-03-28initd: Hand out unique IDs to servicesDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <goliath@infraroot.at>
2019-03-27Add filter argument to status requestDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <goliath@infraroot.at>
2019-03-25Fix: actually process SIGUSR1 in initdDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <goliath@infraroot.at>
2019-03-20Fix warnings from gcc 8.3 + musl buildDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <goliath@infraroot.at>
2019-03-20initd: don't start runsvc for services without exec blockDavid Oberhollenzer
First in rdsvc, tag the services that *do* have exec lines, even if we don't read them. Second, if a service does not have that flag set, don't try to execute it. Signed-off-by: David Oberhollenzer <goliath@infraroot.at>
2019-03-18Cleanup status reportingDavid Oberhollenzer
- mimic format of initd - skip formatting if not a tty - distinguish exited because failed vs exited because done Signed-off-by: David Oberhollenzer <goliath@infraroot.at>
2019-03-18initd: implement handling of socket requestsDavid Oberhollenzer
Actually process requests and send an answer to status inquiries. Signed-off-by: David Oberhollenzer <goliath@infraroot.at>
2019-03-18Add init socket to initdDavid Oberhollenzer
Create a socket if boot target is done. Close and reopen socket if SIGUSR1 is received. Signed-off-by: David Oberhollenzer <goliath@infraroot.at>