mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-28 17:52:43 +01:00
Make bin/aphlict behave slightly better when forking
Summary: Due to how file descriptors get inherited when a process forks and the way our script to start/restart stuff works, having bin/aphlict not close STDOUT caused our script to hang. This diff provides a solution; however, something like https://secure.phabricator.com/diffusion/PHU/browse/master/src/daemon/PhutilDaemonOverseer.php;b45eea975f6d9afc$127-129 may be better or more robust. Test Plan: Run our script that calls bin/aphlict in passthru() and see that it no longer hangs. Reviewers: epriestley, vrana Reviewed By: epriestley CC: aran, Korvin Differential Revision: https://secure.phabricator.com/D4240
This commit is contained in:
parent
776a240870
commit
53115007ff
1 changed files with 7 additions and 0 deletions
|
@ -89,6 +89,13 @@ if ($foreground) {
|
|||
} else if ($pid) {
|
||||
exit(0);
|
||||
}
|
||||
// When we fork, the child process will inherit its parent's set of open
|
||||
// file descriptors. If the parent process of bin/aphlict is waiting for
|
||||
// bin/aphlict's file descriptors to close, it will be stuck waiting on
|
||||
// the daemonized process. (This happens if e.g. bin/aphlict is started
|
||||
// in another script using passthru().)
|
||||
fclose(STDOUT);
|
||||
fclose(STDERR);
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue