blob: b9587e13253928daf52ede90ecb70d9f3dc03b1f (
plain)
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
--TEST--
Test pcntl wait functionality
--SKIPIF--
<?php
if (!extension_loaded("pcntl")) print "skip";
elseif (!function_exists("posix_kill")) print "skip posix_kill() not available";
if (PHP_OS == "Darwin") {
die("skip do not run on darwin");
}
?>
--FILE--
<?php
function test_exit_waits(){
print "\n\nTesting pcntl_wifexited and wexitstatus....";
$pid=pcntl_fork();
if ($pid==0) {
sleep(1);
exit(-1);
} else {
$options=0;
pcntl_waitpid($pid, $status, $options);
if ( pcntl_wifexited($status) ) print "\nExited With: ". pcntl_wexitstatus($status);
}
}
function test_exit_signal(){
print "\n\nTesting pcntl_wifsignaled....";
$pid=pcntl_fork();
if ($pid==0) {
while(1);
exit;
} else {
$options=0;
posix_kill($pid, SIGTERM);
pcntl_waitpid($pid, $status, $options);
if ( pcntl_wifsignaled($status) ) {
$signal_print=pcntl_wtermsig($status);
if ($signal_print==SIGTERM) $signal_print="SIGTERM";
print "\nProcess was terminated by signal : ". $signal_print;
}
}
}
function test_stop_signal(){
print "\n\nTesting pcntl_wifstopped and pcntl_wstopsig....";
$pid=pcntl_fork();
if ($pid==0) {
sleep(1);
exit;
} else {
$options=WUNTRACED;
posix_kill($pid, SIGSTOP);
pcntl_waitpid($pid, $status, $options);
if ( pcntl_wifstopped($status) ) {
$signal_print=pcntl_wstopsig($status);
if ($signal_print==SIGSTOP) $signal_print="SIGSTOP";
print "\nProcess was stoped by signal : ". $signal_print;
}
posix_kill($pid, SIGCONT);
}
}
print "Staring wait.h tests....";
test_exit_waits();
test_exit_signal();
test_stop_signal();
?>
--EXPECT--
Staring wait.h tests....
Testing pcntl_wifexited and wexitstatus....
Exited With: 255
Testing pcntl_wifsignaled....
Process was terminated by signal : SIGTERM
Testing pcntl_wifstopped and pcntl_wstopsig....
Process was stoped by signal : SIGSTOP
|