mirror of
https://github.com/danog/process.git
synced 2024-11-30 04:39:04 +01:00
Send signals to child process instead of wrapper
This commit is contained in:
parent
ab53d92776
commit
d51bd9a487
@ -204,10 +204,13 @@ final class Runner implements ProcessRunner
|
|||||||
/** @inheritdoc */
|
/** @inheritdoc */
|
||||||
public function signal(ProcessHandle $handle, int $signo)
|
public function signal(ProcessHandle $handle, int $signo)
|
||||||
{
|
{
|
||||||
/** @var Handle $handle */
|
$handle->pidDeferred->promise()->onResolve(function ($error, $pid) use ($signo) {
|
||||||
if (!\proc_terminate($handle->proc, $signo)) {
|
if ($error) {
|
||||||
throw new ProcessException("Sending signal to process failed");
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@\posix_kill($pid, $signo);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @inheritdoc */
|
/** @inheritdoc */
|
||||||
|
@ -375,6 +375,17 @@ class ProcessTest extends TestCase
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testSignal()
|
||||||
|
{
|
||||||
|
Loop::run(function () {
|
||||||
|
$process = new Process(["php", __DIR__ . "/bin/signal-process.php"]);
|
||||||
|
yield $process->start();
|
||||||
|
yield new Delayed(100); // Give process time to set up single handler.
|
||||||
|
$process->signal(\SIGTERM);
|
||||||
|
$this->assertSame(42, yield $process->join());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
public function testDebugInfo()
|
public function testDebugInfo()
|
||||||
{
|
{
|
||||||
Loop::run(function () {
|
Loop::run(function () {
|
||||||
|
Loading…
Reference in New Issue
Block a user