{"record":{"id":"da99017a80ed580b","repo":"symfony/process","slug":"setting-ignored-signals-while-the-process-is-running-is-not","errorCode":null,"errorMessage":"Setting ignored signals while the process is running is not possible.","messagePattern":"Setting ignored signals while the process is running is not possible\\.","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"Process.php","lineNumber":1278,"sourceCode":"\n        foreach ($options as $key => $value) {\n            if (!\\in_array($key, $existingOptions)) {\n                $this->options = $defaultOptions;\n                throw new LogicException(\\sprintf('Invalid option \"%s\" passed to \"%s()\". Supported options are \"%s\".', $key, __METHOD__, implode('\", \"', $existingOptions)));\n            }\n            $this->options[$key] = $value;\n        }\n    }\n\n    /**\n     * Defines a list of posix signals that will not be propagated to the process.\n     *\n     * @param list<\\SIG*> $signals\n     */\n    public function setIgnoredSignals(array $signals): void\n    {\n        if ($this->isRunning()) {\n            throw new RuntimeException('Setting ignored signals while the process is running is not possible.');\n        }\n\n        $this->ignoredSignals = $signals;\n    }\n\n    /**\n     * Returns whether TTY is supported on the current operating system.\n     */\n    public static function isTtySupported(): bool\n    {\n        static $isTtySupported;\n\n        return $isTtySupported ??= ('/' === \\DIRECTORY_SEPARATOR && stream_isatty(\\STDOUT) && @is_writable('/dev/tty'));\n    }\n\n    /**\n     * Returns whether PTY is supported on the current operating system.\n     */","sourceCodeStart":1260,"sourceCodeEnd":1296,"githubUrl":"https://github.com/symfony/process/blob/99b85026db14a68f02c6f3eeb01a1170ca25c491/Process.php#L1260-L1296","documentation":"setIgnoredSignals() stores signals to ignore for the process, but this configuration can only happen before the process starts. Once isRunning() is true the OS process already exists and signal dispositions cannot be applied, so a RuntimeException is thrown.","triggerScenarios":"Calling $process->setIgnoredSignals([SIGTERM]) after start()/run() while the child process is still alive.","commonSituations":"Trying to reconfigure ignored signals mid-run in long-lived workers, calling setIgnoredSignals from a callback or after wait() hasn't yet returned but process still runs.","solutions":["Call setIgnoredSignals() before start() or run()","Check $process->isRunning() before calling and defer the change to a fresh process","Stop the process, change signals, restart"],"exampleFix":"// before\n$process->start();\n$process->setIgnoredSignals([SIGTERM]);\n// after\n$process->setIgnoredSignals([SIGTERM]);\n$process->start();","handlingStrategy":"validation","validationCode":"if (!$process->isRunning()) {\n    $process->setIgnoredSignals([SIGTERM]);\n}","typeGuard":null,"tryCatchPattern":"try { $process->setIgnoredSignals($signals); } catch (RuntimeException $e) { /* process already running; defer to restart */ }","preventionTips":["Configure all process settings (env, timeout, signals, options) before start()","Centralize process setup in one factory function","Assert !isRunning() in debug builds before configuration calls"],"tags":["php","process","signals","lifecycle"],"backgroundTag":"invalid-state-transition","analyzedSha":"99b85026db14a68f02c6f3eeb01a1170ca25c491","analyzedAt":"2026-09-14T11:23:33.683Z","contentChangedAt":"2026-09-14T11:23:33.683Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}