Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/Process.php
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,9 @@ public function close()
return;
}

$process = $this->process;
$this->process = null;

foreach ($this->pipes as $pipe) {
$pipe->close();
}
Expand All @@ -306,8 +309,7 @@ public function close()
$this->closeExitCodePipe();
}

$exitCode = \proc_close($this->process);
$this->process = null;
$exitCode = \proc_close($process);

if ($this->exitCode === null && $exitCode !== -1) {
$this->exitCode = $exitCode;
Expand Down
22 changes: 22 additions & 0 deletions tests/AbstractProcessTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1099,6 +1099,28 @@ function ($output) use (&$stdErr) {
$loop->run();
}

public function testIssue116()
{
if (DIRECTORY_SEPARATOR === '\\') {
$this->markTestSkipped('Process pipes not supported on Windows');
}

$loop = $this->createLoop();
$process = new Process('exit 0');

$process->start($loop);

// through some chain
$process->stdout->on('close', function () use ($process) {
$process->close();
});

$process->close();
$loop->stop();

$this->assertFalse($process->isRunning());
}

/**
* Execute a callback at regular intervals until it returns successfully or
* a timeout is reached.
Expand Down