Detecting process termination
In an embedded application, it's often important to detect if any process terminates prematurely and, if so, to handle it. Handling it may involve something as simple as restarting the process or as complex as:
- Notifying other processes that they should put their systems into a safe state.
- Resetting the hardware.
This is complicated by the fact that some Neutrino processes call procmgr_daemon() . Processes that call this function are referred to as daemons. The procmgr_daemon() function:
- detaches the caller from the controlling terminal
- puts it in session 1
- optionally, closes all file descriptors except stdin, stdout, and stderr
- optionally, redirects stdin, stdout, stderr to /dev/null
As a result of the above, their termination is hard to detect.
Another scenario is where a server process wants to know if any of its clients disappear so that it can clean up any resources it had set aside on their behalf.
Let's look at various ways of detecting process termination.