Skip to content

Commit c79b4c1

Browse files
authored
Merge pull request #51 from puggan/issue-50
Switch from kill-all-exit to a normal exit when a child is done
2 parents ee80755 + 90a6193 commit c79b4c1

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

src/Fork.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ protected function forkForTask(Task $task): Task
129129
try {
130130
$this->executeInChildTask($task, $socketToParent);
131131
} finally {
132-
$this->exit();
132+
exit();
133133
}
134134
}
135135

tests/ForkTest.php

+14
Original file line numberDiff line numberDiff line change
@@ -138,3 +138,17 @@ function () {
138138
fn () => 1
139139
);
140140
});
141+
142+
test('allow 2nd process to be done before the 1st')
143+
->expect(
144+
fn () => Fork::new()->run(
145+
static function () {
146+
usleep(200_000);
147+
return 2;
148+
},
149+
static function () {
150+
usleep(100_000);
151+
return 1;
152+
},
153+
)
154+
)->toEqual([2,1]);

0 commit comments

Comments
 (0)