Process::start with TimeoutCancellation stops running process on Windows
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 260
- Forks
- 29
- PR merge metrics
- No merged PRs in 30d
Description
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the supplied Process::start test script and run it on both Windows and Linux to reproduce the different cancellation behavior. Inspect the Process::start cancellation handling, then establish whether cancellation should stop only startup or also the process; done means the intended behavior is consistent across platforms and the cancellation parameter is documented.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- operating-systems
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100