1--TEST--
2proc_open
3--SKIPIF--
4<?php
5if (!is_executable('/bin/sleep')) echo 'skip no sleep';
6if (getenv('SKIP_SLOW_TESTS')) echo 'skip slow test';
7?>
8--FILE--
9<?php
10$ds = array(array('pipe', 'r'));
11
12$cat = proc_open(
13    ['/bin/sleep', '2'],
14    $ds,
15    $pipes
16);
17
18usleep(20000); // let the OS run the sleep process before sending the signal
19
20var_dump(proc_terminate($cat, 0)); // status check
21usleep(20000);
22var_dump(proc_get_status($cat));
23
24var_dump(proc_terminate($cat)); // now really quit it
25usleep(20000);
26var_dump(proc_get_status($cat));
27
28proc_close($cat);
29
30echo "Done!\n";
31
32?>
33--EXPECTF--
34bool(true)
35array(9) {
36  ["command"]=>
37  string(10) "/bin/sleep"
38  ["pid"]=>
39  int(%d)
40  ["cached"]=>
41  bool(false)
42  ["running"]=>
43  bool(true)
44  ["signaled"]=>
45  bool(false)
46  ["stopped"]=>
47  bool(false)
48  ["exitcode"]=>
49  int(-1)
50  ["termsig"]=>
51  int(0)
52  ["stopsig"]=>
53  int(0)
54}
55bool(true)
56array(9) {
57  ["command"]=>
58  string(10) "/bin/sleep"
59  ["pid"]=>
60  int(%d)
61  ["cached"]=>
62  bool(false)
63  ["running"]=>
64  bool(false)
65  ["signaled"]=>
66  bool(true)
67  ["stopped"]=>
68  bool(false)
69  ["exitcode"]=>
70  int(-1)
71  ["termsig"]=>
72  int(15)
73  ["stopsig"]=>
74  int(0)
75}
76Done!
77