forked from php/php-src
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gh11498.phpt
43 lines (39 loc) · 805 Bytes
/
gh11498.phpt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
--TEST--
GH-11498 (SIGCHLD is not always returned from proc_open)
--EXTENSIONS--
pcntl
--SKIPIF--
<?php
if (PHP_OS != 'Linux') {
die('skip Linux only');
}
?>
--FILE--
<?php
$processes = [];
pcntl_async_signals(true);
pcntl_signal(SIGCHLD, function($sig, $info) use (&$processes) {
echo "SIGCHLD\n";
unset($processes[$info['pid']]);
}, false);
for ($i = 0; $i <= 5; $i++) {
// Sleeping ensures we get to add the process to the list before the signal is invoked.
$process = proc_open('sleep 1', [], $pipes);
$pid = proc_get_status($process)['pid'];
$processes[$pid] = $process;
}
$iters = 50;
while (!empty($processes) && $iters > 0) {
usleep(100_000);
$iters--;
}
var_dump(empty($processes));
?>
--EXPECT--
SIGCHLD
SIGCHLD
SIGCHLD
SIGCHLD
SIGCHLD
SIGCHLD
bool(true)