1--TEST--
2Bug #39322 (proc_terminate() losing process resource)
3--SKIPIF--
4<?php
5if (getenv("SKIP_SLOW_TESTS")) die("skip slow test");
6if (!is_executable('/bin/sleep')) echo 'skip sleep not found';
7?>
8--FILE--
9<?php
10$descriptors = array(
11    0 => array('pipe', 'r'),
12    1 => array('pipe', 'w'),
13    2 => array('pipe', 'w'));
14
15$pipes = array();
16
17$process = proc_open('/bin/sleep 120', $descriptors, $pipes);
18
19proc_terminate($process, 9);
20sleep(1); // wait a bit to let the process finish
21var_dump(proc_get_status($process));
22
23echo "Done!\n";
24
25?>
26--EXPECTF--
27array(8) {
28  ["command"]=>
29  string(14) "/bin/sleep 120"
30  ["pid"]=>
31  int(%d)
32  ["running"]=>
33  bool(false)
34  ["signaled"]=>
35  bool(true)
36  ["stopped"]=>
37  bool(false)
38  ["exitcode"]=>
39  int(-1)
40  ["termsig"]=>
41  int(9)
42  ["stopsig"]=>
43  int(0)
44}
45Done!
46