Add supervisor

This commit is contained in:
Nils O. Selåsdal
2013-08-28 23:25:02 +02:00
parent 13108f1f48
commit 110c843d9d
2 changed files with 216 additions and 0 deletions
+22
View File
@@ -0,0 +1,22 @@
#ifndef UCORE_SUPERVISOR_H_
#define UCORE_SUPERVISOR_H_
/** Supervises this process - restart if it dies.
*
* The program should call supervise() at a pristine state (all relevant file descriptors closed, etc).
* supervise() will return 0 if all is ok, and the program can continue.(returning != 0 means
* the supervisor couldn't start, and the calling process must exit)
*
* This will run the actual process as a child process. If that child process dies by any means,
* supervise will create another child process, where supervise() returns 0 again.
*
* To kill the supervisor process and the supervised process, send SIGERM/SIGHUP/SIGINT to the
* parent supervisor process.
* Sending SIGUSR1 to the parent supervisor process will terminate the current child process and
* restart it.
*
* The supervised child process must exit if it recieves a SIGTERM
* @return 0 on success, non-zero on failure (e.g. fork() fails)*/
int uc_supervise(void);
#endif