Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F14007046
D15977.id.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
4 KB
Referenced Files
None
Subscribers
None
D15977.id.diff
View Options
diff --git a/scripts/daemon/exec/exec_daemon.php b/scripts/daemon/exec/exec_daemon.php
--- a/scripts/daemon/exec/exec_daemon.php
+++ b/scripts/daemon/exec/exec_daemon.php
@@ -1,6 +1,8 @@
#!/usr/bin/env php
<?php
+declare(ticks = 1);
+
require_once dirname(__FILE__).'/../../__init_script__.php';
if (!posix_isatty(STDOUT)) {
diff --git a/src/daemon/PhutilDaemon.php b/src/daemon/PhutilDaemon.php
--- a/src/daemon/PhutilDaemon.php
+++ b/src/daemon/PhutilDaemon.php
@@ -73,7 +73,6 @@
private static $sighandlerInstalled;
final public function __construct(array $argv) {
- declare(ticks = 1);
$this->argv = $argv;
if (!self::$sighandlerInstalled) {
@@ -81,7 +80,7 @@
pcntl_signal(SIGTERM, __CLASS__.'::exitOnSignal');
}
- pcntl_signal(SIGINT, array($this, 'onGracefulSignal'));
+ pcntl_signal(SIGINT, array($this, 'onGracefulSignal'));
pcntl_signal(SIGUSR2, array($this, 'onNotifySignal'));
// Without discard mode, this consumes unbounded amounts of memory. Keep
@@ -102,7 +101,7 @@
$daemon = get_class($this);
fprintf(
STDERR,
- "<%s> %s %s\n",
+ "%s %s %s\n",
'<RAMS>',
$daemon,
pht(
@@ -168,7 +167,9 @@
}
public static function exitOnSignal($signo) {
- // Normally, PHP doesn't invoke destructors when existing in response to
+ self::didCatchSignal($signo);
+
+ // Normally, PHP doesn't invoke destructors when exiting in response to
// a signal. This forces it to do so, so we have a fighting chance of
// releasing any locks, leases or resources on our way out.
exit(128 + $signo);
@@ -207,10 +208,12 @@
}
final public function onGracefulSignal($signo) {
+ self::didCatchSignal($signo);
$this->inGracefulShutdown = true;
}
final public function onNotifySignal($signo) {
+ self::didCatchSignal($signo);
$this->notifyReceived = true;
$this->onNotify($signo);
}
@@ -230,10 +233,20 @@
final protected function log($message) {
if ($this->verbose) {
$daemon = get_class($this);
- fprintf(STDERR, "<%s> %s %s\n", '<VERB>', $daemon, $message);
+ fprintf(STDERR, "%s %s %s\n", '<VERB>', $daemon, $message);
}
}
+ private static function didCatchSignal($signo) {
+ $signame = phutil_get_signal_name($signo);
+ fprintf(
+ STDERR,
+ "%s Caught signal %s (%s).\n",
+ '<SGNL>',
+ $signo,
+ $signame);
+ }
+
/* -( Communicating With the Overseer )------------------------------------ */
@@ -250,6 +263,7 @@
if (!strlen($data)) {
return '';
}
+
return $this->encodeOverseerMessage(self::MESSAGETYPE_STDOUT, $data);
}
diff --git a/src/daemon/PhutilDaemonHandle.php b/src/daemon/PhutilDaemonHandle.php
--- a/src/daemon/PhutilDaemonHandle.php
+++ b/src/daemon/PhutilDaemonHandle.php
@@ -107,13 +107,16 @@
$stderr = trim($stderr);
if (strlen($stderr)) {
- $this->logMessage('STDE', $stderr);
+ foreach (phutil_split_lines($stderr, false) as $line) {
+ $this->logMessage('STDE', $line);
+ }
}
if ($result !== null) {
list($err) = $result;
+
if ($err) {
- $this->logMessage('FAIL', pht('Process exited with error %s', $err));
+ $this->logMessage('FAIL', pht('Process exited with error %s.', $err));
} else {
$this->logMessage('DONE', pht('Process exited normally.'));
}
diff --git a/src/future/exec/ExecFuture.php b/src/future/exec/ExecFuture.php
--- a/src/future/exec/ExecFuture.php
+++ b/src/future/exec/ExecFuture.php
@@ -767,8 +767,18 @@
fclose($stderr);
}
+ // If the subprocess got nuked with `kill -9`, we get a -1 exitcode.
+ // Upgrade this to a slightly more informative value by examining the
+ // terminating signal code.
+ $err = $status['exitcode'];
+ if ($err == -1) {
+ if ($status['signaled']) {
+ $err = 128 + $status['termsig'];
+ }
+ }
+
$this->result = array(
- $status['exitcode'],
+ $err,
$this->stdout,
$this->stderr,
);
@@ -854,6 +864,7 @@
}
}
$this->procStatus = proc_get_status($this->proc);
+
return $this->procStatus;
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Oct 29, 10:51 PM (1 w, 2 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6717290
Default Alt Text
D15977.id.diff (4 KB)
Attached To
Mode
D15977: Make many minor improvements to daemon behavior
Attached
Detach File
Event Timeline
Log In to Comment