xref: /PHP-7.4/ext/pcntl/tests/pcntl_wait.phpt (revision 2fa4e79e)
1--TEST--
2pcntl_wait()
3--SKIPIF--
4<?php if (!extension_loaded("pcntl")) print "skip"; ?>
5<?php if (!extension_loaded("posix")) die("skip posix extension not available"); ?>
6--FILE--
7<?php
8$pid = pcntl_fork();
9if ($pid == -1) {
10	die("failed");
11} else if ($pid) {
12	$status = 0;
13	pcntl_wait($status, WUNTRACED);
14	var_dump(pcntl_wifexited($status));
15	posix_kill($pid, SIGCONT);
16
17	pcntl_wait($status);
18	var_dump(pcntl_wifsignaled($status));
19	var_dump(pcntl_wifstopped($status));
20	var_dump(pcntl_wexitstatus($status));
21
22	var_dump(pcntl_wait($status, WNOHANG | WUNTRACED));
23	var_dump(pcntl_wait());
24	var_dump(pcntl_waitpid());
25
26	var_dump(pcntl_wifexited());
27	var_dump(pcntl_wifstopped());
28	var_dump(pcntl_wifsignaled());
29	var_dump(pcntl_wexitstatus());
30	var_dump(pcntl_wtermsig());
31	var_dump(pcntl_wstopsig());
32} else {
33	posix_kill(posix_getpid(), SIGSTOP);
34	exit(42);
35}
36?>
37--EXPECTF--
38bool(false)
39bool(false)
40bool(false)
41int(42)
42int(-1)
43
44Warning: pcntl_wait() expects at least 1 parameter, 0 given in %s
45NULL
46
47Warning: pcntl_waitpid() expects at least 2 parameters, 0 given in %s
48NULL
49
50Warning: pcntl_wifexited() expects exactly 1 parameter, 0 given in %s
51NULL
52
53Warning: pcntl_wifstopped() expects exactly 1 parameter, 0 given in %s
54NULL
55
56Warning: pcntl_wifsignaled() expects exactly 1 parameter, 0 given in %s
57NULL
58
59Warning: pcntl_wexitstatus() expects exactly 1 parameter, 0 given in %s
60NULL
61
62Warning: pcntl_wtermsig() expects exactly 1 parameter, 0 given in %s
63NULL
64
65Warning: pcntl_wstopsig() expects exactly 1 parameter, 0 given in %s
66NULL
67