symfony/process · error · RuntimeException

Disabling output while the process is running is not…

Error message

Disabling output while the process is running is not possible.

What it means

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.

Solutions

  1. Move disableOutput() before the start()/run() call.
  2. Guard the call with if (!$process->isRunning()) before disabling output.
  3. Recreate the process object with the desired output configuration and start it again.
  4. If output is truly unwanted, set it once at construction or use getProcess() with output disabled from the start.

Example fix

// before
$process->start();
$process->disableOutput(); // RuntimeException

// after
$process->disableOutput();
$process->start();
Defensive patterns

Strategy: validation

Validate before calling

if (!$process->isRunning()) {
    $process->disableOutput();
}

Try / catch

try {
    $process->disableOutput();
} catch (\RuntimeException $e) {
    // process already running; reconfigure by recreating the process
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: "Invalid state transition" errors: "status must be X, actually Y", "already rejected/charging/uninstalled", "cannot ... while running" — what they mean when a library rejects your call — this error's family across 31 libraries.

Related errors


AI-assisted analysis of symfony/process@99b85026db (2026-09-14). Data as JSON: /api/errors/2438d6087bc4b496. Report an issue: GitHub.

Appendix: source

Thrown at Process.php:591

    public function signal(int $signal): static
    {
        $this->doSignal($signal, true);

        return $this;
    }

    /**
     * Disables fetching output and error output from the underlying process.
     *
     * @return $this
     *
     * @throws RuntimeException In case the process is already running
     * @throws LogicException   if an idle timeout is set
     */
    public function disableOutput(): static
    {
        if ($this->isRunning()) {
            throw new RuntimeException('Disabling output while the process is running is not possible.');
        }
        if (null !== $this->idleTimeout) {
            throw new LogicException('Output cannot be disabled while an idle timeout is set.');
        }

        $this->outputDisabled = true;

        return $this;
    }

    /**
     * Enables fetching output and error output from the underlying process.
     *
     * @return $this
     *
     * @throws RuntimeException In case the process is already running
     */
    public function enableOutput(): static

View on GitHub (pinned to 99b85026db)