1
0
mirror of https://github.com/danog/process.git synced 2024-11-30 04:39:04 +01:00

Fix isRunning

start() is 'blocking' and might take some time to return.
This commit is contained in:
Niklas Keller 2018-07-23 18:09:06 +02:00
parent 11aea03cfa
commit 75ec5b7c08

View File

@ -30,6 +30,9 @@ class Process
/** @var ProcessHandle */
private $handle;
/** @var bool */
private $starting = false;
/**
* @param string|string[] $command Command to run.
* @param string|null $cwd Working directory or use an empty string to use the working directory of the
@ -89,7 +92,12 @@ class Process
throw new StatusError("Process has already been started.");
}
$this->handle = $this->processRunner->start($this->command, $this->cwd, $this->env, $this->options);
try {
$this->starting = true;
$this->handle = $this->processRunner->start($this->command, $this->cwd, $this->env, $this->options);
} finally {
$this->starting = false;
}
}
/**
@ -208,7 +216,7 @@ class Process
*/
public function isRunning(): bool
{
return $this->handle && $this->handle->status !== ProcessStatus::ENDED;
return $this->starting || ($this->handle && $this->handle->status !== ProcessStatus::ENDED);
}
/**