Skip to content

[Process] Output capture with PTY=true does not work very well #59927

@lyrixx

Description

@lyrixx

Symfony version(s) affected

all

Description

When running a process, with PTY=true, the output (STDOUT) is not well captured.
Sometimes, it does not work. It looks like the output is instead saved in STDERR

How to reproduce

<?php

require 'vendor/autoload.php';

use Symfony\Component\Process\Process;

$reference = run_process();

echo "Output Reference:\n";
echo $reference;
echo "\n";

for ($i=0; $i < 100_000; $i++) {
    if ($i > 0 && $i % 80 === 0) {
        echo "\n";
    }
    echo '.';
    $output = run_process();
    if ($output !== $reference) {
        echo "\n!!Output changed!!\n";
        echo "New output:\n";
        echo "$output\n";
        exit(1);
    }
}

function run_process(){
    $process = new Process(['cat', __FILE__]);
    // If you comment the following line, the test become stable
    $process->setPty(true);
    $process->mustRun();

    return $process->getOutput();
}

Possible Solution

No response

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions