amphp / amphp/process

Process::start with TimeoutCancellation stops running process on Windows

Open
#79 0 comments 0 reactions 0 assignees View on GitHub

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.