ruby - Ensure orphaned processes are killed when the parent process dies -


in ruby, how ensure child processes spawned program don't keep running when main process exits or killed?

initially thought use at_exit in main process, won't work if main process gets kill -9ed or calls kernel.exec. need solution (basically) foolproof, , cross-platform.

if have handle kill -9 termination parent app, have couple of choices can see:

  • create work queue manager , spawn/kill child processes work queue manager. if can't guarantee work queue manager won't killed without warning, option 2 choice think, since thing know sure child processes still running.
  • have child processes check "heartbeat" parent process through rpc or monitoring parent pid in memory or watching date/time on keep-alive file in /tmp make sure it's current.
    • if child processes fail see parent processes doing it's job of either responding rpc messages, staying in memory itself, or keeping file date/time current child processes must kill themselves.

Comments

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

java - Digest auth with Spring Security using javaconfig -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -