Skip to content

Commit df4c1f3

Browse files
committed
Call ProcessPromise::cancel() from deferred canceller
1 parent 4d58c28 commit df4c1f3

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/Process/ProcessPromise.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ final class ProcessPromise
2424

2525
public function __construct(private LoopInterface $loop, private string $name, private string $command)
2626
{
27-
$this->deferred = new Deferred();
27+
$this->deferred = new Deferred(function (): void {
28+
$this->cancel();
29+
});
2830
}
2931

3032
public function getName(): string
@@ -85,7 +87,7 @@ public function run(): PromiseInterface
8587
return $this->deferred->promise();
8688
}
8789

88-
public function cancel(): void
90+
private function cancel(): void
8991
{
9092
if ($this->process === null) {
9193
throw new ShouldNotHappenException('Cancelling process before running');

0 commit comments

Comments
 (0)