Page MenuHomePhabricator

Make many minor improvements to daemon behavior

Authored by epriestley on May 26 2016, 3:19 AM.
Referenced Files
Unknown Object (File)
Fri, Mar 17, 12:12 AM
Unknown Object (File)
Mon, Mar 13, 8:46 PM
Unknown Object (File)
Wed, Mar 1, 2:03 PM
Unknown Object (File)
Feb 26 2023, 2:36 AM
Unknown Object (File)
Feb 16 2023, 2:02 PM
Unknown Object (File)
Feb 14 2023, 6:55 PM
Unknown Object (File)
Feb 5 2023, 2:23 AM
Unknown Object (File)
Feb 1 2023, 8:25 PM



Ref T10811.

First, declare() at constructor scope doesn't actually work properly, because PHP is a beautiful language full of wonderful and interesting ideas. Instead, it affects file scope (or something???). In practice, this is often the same thing, except that sometimes it isn't.

To reproduce this, run:

libphutil/ $ echo '{}' | php ./scripts/daemon/exec/exec_daemon.php PhutilHangForeverDaemon --verbose

Then send it SIGTERM. Before the change, it ignores the signal. Now, it exits properly.

Second, stuff was printing <<VERB>> and such by accident because of typos. Fix the extra <> so this just prints <VERB>. I observed proper terminal output after this patch.

Third, always print when we catch a signal. Hopefully this will help identify possible problems related to rogue signals. I observed messages about caught signals.

Fourth, when a script emits some text on stderr, print each line separately. This aligns things better and makes them easier to read. I observed multi-line messages spread across multiple lines with headers on each line, aligning more readably.

Fifth, add a missing period

Sixth, after a subprocess gets kill -9'd, exit with error code 128 + 9 (137) instead of -1 (and likewise for other signal codes, if any exist). I kill -9'd a daemon and saw a more useful exit code.

Test Plan

See above for particulars.

Also ran bin/phd debug ... and signaled processes, observed normal operation and more useful log output.

Diff Detail

rPHU libphutil
Lint Not Applicable
Tests Not Applicable

Event Timeline

epriestley retitled this revision from to Make many minor improvements to daemon behavior.
epriestley updated this object.
epriestley edited the test plan for this revision. (Show Details)
epriestley added a reviewer: chad.
chad edited edge metadata.
This revision is now accepted and ready to land.May 26 2016, 4:11 AM
This revision was automatically updated to reflect the committed changes.