{"record":{"id":"2438d6087bc4b496","repo":"symfony/process","slug":"disabling-output-while-the-process-is-running-is-not","errorCode":null,"errorMessage":"Disabling output while the process is running is not possible.","messagePattern":"Disabling output while the process is running is not possible\\.","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"Process.php","lineNumber":591,"sourceCode":"    public function signal(int $signal): static\n    {\n        $this->doSignal($signal, true);\n\n        return $this;\n    }\n\n    /**\n     * Disables fetching output and error output from the underlying process.\n     *\n     * @return $this\n     *\n     * @throws RuntimeException In case the process is already running\n     * @throws LogicException   if an idle timeout is set\n     */\n    public function disableOutput(): static\n    {\n        if ($this->isRunning()) {\n            throw new RuntimeException('Disabling output while the process is running is not possible.');\n        }\n        if (null !== $this->idleTimeout) {\n            throw new LogicException('Output cannot be disabled while an idle timeout is set.');\n        }\n\n        $this->outputDisabled = true;\n\n        return $this;\n    }\n\n    /**\n     * Enables fetching output and error output from the underlying process.\n     *\n     * @return $this\n     *\n     * @throws RuntimeException In case the process is already running\n     */\n    public function enableOutput(): static","sourceCodeStart":573,"sourceCodeEnd":609,"githubUrl":"https://github.com/symfony/process/blob/99b85026db14a68f02c6f3eeb01a1170ca25c491/Process.php#L573-L609","documentation":"Symfony Process throws this RuntimeException from disableOutput() when the caller tries to disable output collection on a process that has already been started and is still running. Output capture must be configured before start(), because the process pipes/streams are set up at start time. Disabling mid-run would corrupt or truncate output handling, so it is rejected.","triggerScenarios":"Calling Process::disableOutput() after start()/run() while isRunning() is true. Seen in tests like testOptionCreateNewConsole and testItReturnsFastAfterStart when disableOutput is invoked on a live process.","commonSituations":"Configuring a process object that a shared service already started; calling setters after run() instead of before; building fluent configuration that executes after an earlier start call; long-running background process whose lifecycle the caller lost track of.","solutions":["Move disableOutput() before the start()/run() call.","Guard the call with if (!$process->isRunning()) before disabling output.","Recreate the process object with the desired output configuration and start it again.","If output is truly unwanted, set it once at construction or use getProcess() with output disabled from the start."],"exampleFix":"// before\n$process->start();\n$process->disableOutput(); // RuntimeException\n\n// after\n$process->disableOutput();\n$process->start();","handlingStrategy":"validation","validationCode":"if (!$process->isRunning()) {\n    $process->disableOutput();\n}","typeGuard":null,"tryCatchPattern":"try {\n    $process->disableOutput();\n} catch (\\RuntimeException $e) {\n    // process already running; reconfigure by recreating the process\n}","preventionTips":["Do all output/timeout/input configuration in a builder step that always precedes start().","Never share a Process instance between the configuring and the running phase of an application."],"tags":["process","symfony","runtime-exception","invalid-state-transition"],"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"}