xref: /PHP-8.0/ext/pcntl/tests/pcntl_wait.phpt (revision 0c6d06ec)
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} else {
24    posix_kill(posix_getpid(), SIGSTOP);
25    exit(42);
26}
27?>
28--EXPECT--
29bool(false)
30bool(false)
31bool(false)
32int(42)
33int(-1)
34