hyperboria / bugs

Peer-to-peer IPv6 networking, secure and near-zero-conf.
154 stars 17 forks source link

client: exit foreground process when core dies #22

Closed ghost closed 9 years ago

ghost commented 9 years ago

Many init scripts run cjdroute in foreground, so they can easily send signals and fetch logs. They can however not monitor cjdroute, because the foreground process doesn't keep track of the forked core process. Thus recovery in case of crashes requires a manual restart of cjdroute.

With this patch, once the core process exits, the foreground process prints the exit code and the signal which caused the exit. It then exits, too, and the init script can restart it.

ghost commented 9 years ago
not bad... the professional thing to do is call back Process_OnExit() with a void\* pointer which is passed in to Process_spawn() so that someone who wanted to do something other than exit when the child process died would be able to regain their state.
ghost commented 9 years ago
cjd: i don't quite unterstand the comment regarding being able to regain their state on exit you can pass any function that satisfies Process_OnExitCallback yeah but the function should have 1 more arg arbitrary user data which is passed in before anyway not needed for your purpose oh yeah userdata ain't gonna need it