{"record":{"id":"18b0833edcb5c1c5","repo":"symfony/process","slug":"input-cannot-be-set-while-the-process-is-running","errorCode":null,"errorMessage":"Input cannot be set while the process is running.","messagePattern":"Input cannot be set while the process is running\\.","errorType":"exception","errorClass":"LogicException","httpStatus":null,"severity":"error","filePath":"Process.php","lineNumber":1197,"sourceCode":"    {\n        return $this->input;\n    }\n\n    /**\n     * Sets the input.\n     *\n     * This content will be passed to the underlying process standard input.\n     *\n     * @param string|resource|\\Traversable|self|null $input The content\n     *\n     * @return $this\n     *\n     * @throws LogicException In case the process is running\n     */\n    public function setInput(mixed $input): static\n    {\n        if ($this->isRunning()) {\n            throw new LogicException('Input cannot be set while the process is running.');\n        }\n\n        $this->input = ProcessUtils::validateInput(__METHOD__, $input);\n\n        return $this;\n    }\n\n    /**\n     * Performs a check between the timeout definition and the time the process started.\n     *\n     * In case you run a background process (with the start method), you should\n     * trigger this method regularly to ensure the process timeout\n     *\n     * @throws ProcessTimedOutException In case the timeout was reached\n     */\n    public function checkTimeout(): void\n    {\n        if (self::STATUS_STARTED !== $this->status) {","sourceCodeStart":1179,"sourceCodeEnd":1215,"githubUrl":"https://github.com/symfony/process/blob/99b85026db14a68f02c6f3eeb01a1170ca25c491/Process.php#L1179-L1215","documentation":"setInput() throws this LogicException when called on a process that is already running. The child's stdin is established at start time, so input can only be provided while the process is in a not-yet-started or terminated state.","triggerScenarios":"Calling setInput() after start()/run() while isRunning() is true. Also reachable via constructors that call setInput() with input on a reused/running instance.","commonSituations":"Streaming data to a subprocess interactively and trying to change stdin mid-run; retry loops reconfiguring a still-running process; fluent builders invoked after start.","solutions":["Call setInput() before start()/run().","Stop() or wait() for the process to finish before setting new input, then restart if needed.","Provide all input up front at construction: new Process($cmd, null, null, $input).","For interactive mid-run input, use a TTY or communicate()/InputStream from the symfony/process stream API."],"exampleFix":"// before\n$process->start();\n$process->setInput('foo'); // LogicException\n\n// after\n$process->setInput('foo');\n$process->start();","handlingStrategy":"validation","validationCode":"if (!$process->isRunning()) {\n    $process->setInput($input);\n}","typeGuard":null,"tryCatchPattern":"try {\n    $process->setInput($input);\n} catch (\\LogicException $e) {\n    // running: stop() or wait() first, or feed via InputStream\n}","preventionTips":["Pass input at construction: new Process($cmd, $cwd, $env, $input).","For interactive stdin, use symfony/process InputStream with start() instead of setInput()."],"tags":["process","symfony","logic-exception","stdin","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"}