Skip to content

Commit

Permalink
Avoid deadlock in test when sharing process group (#32067)
Browse files Browse the repository at this point in the history
The testSharedGet test spawns child processes and waits for them to
exit. The main process will wait for all child processes in its own
process group.

While this usually works, the processes involved in the test case are
not necessarily the only processes in their process group. Should
PHPUnit itself be executing in a child process, its parent process
will also be there, causing a deadlock.

This change will move the main test process into its own process group
before forking to avoid the aforementioned situation.
  • Loading branch information
rgson authored Mar 23, 2020
1 parent 058751b commit eb26443
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions tests/Filesystem/FilesystemTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,8 @@ public function testSharedGet()
$content = str_repeat('123456', 1000000);
$result = 1;

posix_setpgid(0, 0);

for ($i = 1; $i <= 20; $i++) {
$pid = pcntl_fork();

Expand Down

0 comments on commit eb26443

Please sign in to comment.