diff --git a/lib/AbstractException.php b/lib/AbstractException.php index 968f9e79..501634d4 100644 --- a/lib/AbstractException.php +++ b/lib/AbstractException.php @@ -113,6 +113,7 @@ abstract class AbstractException extends \Exception { "Service/Exception.pidDuplicate" => 10809, "Service/Exception.pidLocked" => 10810, "Service/Exception.pidInaccessible" => 10811, + "Service/Exception.forkFailed" => 10812, ]; protected $symbol; diff --git a/lib/Service/Daemon.php b/lib/Service/Daemon.php index f5ae3d18..ef44ceb8 100644 --- a/lib/Service/Daemon.php +++ b/lib/Service/Daemon.php @@ -30,7 +30,7 @@ class Daemon { switch (@pcntl_fork()) { case -1: // Unable to fork - throw new \Exception("Unable to fork"); + throw new Exception("forkFailed", ['instance' => 1]); case 0: fclose($pipe[0]); # In the child, call setsid() to detach from any terminal and create an independent session. @@ -39,7 +39,7 @@ class Daemon { switch (@pcntl_fork()) { case -1: // Unable to fork - throw new \Exception("Unable to fork"); + throw new Exception("forkFailed", ['instance' => 2]); case 0: // We do some things out of order because as far as I know there's no way to reconnect stdin, stdout, and stderr without closing the channel to the parent first # In the daemon process, write the daemon PID (as returned by getpid()) to a PID file, for example /run/foobar.pid (for a hypothetical daemon "foobar") to ensure that the daemon cannot be started more than once. This must be implemented in race-free fashion so that the PID file is only updated when it is verified at the same time that the PID previously stored in the PID file no longer exists or belongs to a foreign process. diff --git a/locale/en.php b/locale/en.php index a0de1584..01898667 100644 --- a/locale/en.php +++ b/locale/en.php @@ -219,4 +219,5 @@ return [ 'Exception.JKingWeb/Arsse/Service/Exception.pidDuplicate' => 'Service is already running with process identifier {pid}', 'Exception.JKingWeb/Arsse/Service/Exception.pidLocked' => 'PID file "{pidfile}" is locked', 'Exception.JKingWeb/Arsse/Service/Exception.pidInaccessible' => 'Unable to open PID file "{pidfile}"', + 'Exception.JKingWeb/Arsse/Service/Exception.forkFailed' => 'Failed to spawn child process ({instance, ordinal} instance)', ];