diff --git a/src/ProcessUtil.php b/src/ProcessUtil.php new file mode 100644 index 0000000..c7cb5d9 --- /dev/null +++ b/src/ProcessUtil.php @@ -0,0 +1,19 @@ +assertTrue(file_exists('/proc/'.$process_status['pid'])); + + exec('kill -0 '.$process_status['pid'], $output, $exit_code); + + $this->assertEquals(0, $exit_code); + + $this->assertNotFalse(posix_getpgid($process_status['pid'])); + + $time_start = time(); + + ProcessUtil::killTree($process_status['pid']); + + while (true) { + $process_status = proc_get_status($process); + + if ($process_status['running'] === false) { + break; + } + } + + $this->assertFalse($process_status['running']); + $this->assertEquals(-1, $process_status['exitcode']); + + $time_end = time(); + + $this->assertTrue($time_end - $time_start < 60); + } +}