Skip to content

Process::start with TimeoutCancellation stops running process on Windows #79

Description

@3DFace

I'm not sure if this is a bug or intentional. Could you help me figure it out please?

The cancellation parameter isn't described in PHPDOC, but I assume it's intended to cancel the startup procedure, not the process itself.

The behavior is different on Linux and Windows. Which is confusing.

Here is a test script to demonstrate the issue.


<?php

include_once __DIR__.'/vendor/autoload.php';

use Amp\Process\Process;
use Amp\TimeoutCancellation;
use function Amp\delay;

$cmd = PHP_OS_FAMILY === 'Windows' ? 'ping -n 100 127.0.0.1' : 'sleep 100';

echo PHP_OS_FAMILY.', php '.PHP_VERSION."\n";
echo $cmd."\n";

$process = Process::start($cmd, cancellation: new TimeoutCancellation(3, "Startup timeout"));

echo $process->isRunning() ? "running\n" : "stopped\n";

foreach (range(1, 5) as $x) {
	delay(1);
	echo $process->isRunning() ? "running\n" : "stopped\n";
}

$process->kill();

Windows

Windows, php 8.3.14
ping -n 100 127.0.0.1
running
running
running
stopped
stopped
stopped

Linux

Linux, php 8.3.27
sleep 100
running
running
running
running
running
running

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions