A set of utilities for managing background processes.
This is aimed at simple systems with limited layers of functionality.
- Manage persistent background processes, for instance
sshd
andgetty
- Allow starting/stopping daemons on device insertion, for instance
wpa_supplicant
andudhcpc
for a wifi dongle - Manage background scripts or batch jobs
This is not suitable for managing the startup process of complex systems, due
to the simplified design - use an alternative such as systemd
for that.
Key concerns are (in order of importance):
- Complexity
- Reliability and correctness
- Memory usage (process count, structures)
- Speed (mostly bootup/shutdown speed)
The main programs used for interacting with the daemon state are listed below. These programs explicitely stop and start running services.
bh-start
- start a servicebh-stop
- stop a servicebh-stopall
- stop all servicesbh-status
- print the status of a service
To describe dependencies, a refcount-style system is implemented using the programs listed below. By "requiring" another service in the pre script and "releasing" the service in the post script, services can be started and stopped as required, without requiring an explicit dependency tree. These return once the operation has completed.
bh-require
- require a service to be startedbh-release
- release a prior requirement
To manage the daemons several helper utilities are used.
escort
: provide a control socket for a child programconnect
: connect to a socket and wait for a responsesemaphore
: increment or decrement a stored counterstate
: provide atomic access to the contents of a file
Service scripts are stored in a per-service directory. These are expected to be executable files that do not fork and return once completed.
pre
- run before a service startsrun
- the actual service to run (forking services not supported)post
- run after the service stops
Running make
, make install
should be sufficient.
If you feel the need to modify things the makefile
should be quite readable
and src/config.h
contains most of the modifiable declarations.