Skip to content

Commit

Permalink
Merge pull request #51 from puggan/issue-50
Browse files Browse the repository at this point in the history
Switch from kill-all-exit to a normal exit when a child is done
  • Loading branch information
freekmurze authored Dec 7, 2023
2 parents ee80755 + 90a6193 commit c79b4c1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Fork.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ protected function forkForTask(Task $task): Task
try {
$this->executeInChildTask($task, $socketToParent);
} finally {
$this->exit();
exit();
}
}

Expand Down
14 changes: 14 additions & 0 deletions tests/ForkTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,3 +138,17 @@ function () {
fn () => 1
);
});

test('allow 2nd process to be done before the 1st')
->expect(
fn () => Fork::new()->run(
static function () {
usleep(200_000);
return 2;
},
static function () {
usleep(100_000);
return 1;
},
)
)->toEqual([2,1]);

0 comments on commit c79b4c1

Please sign in to comment.