diff options
author | Michael Larabel <michael@phx-laptop.(none)> | 2008-12-04 15:07:07 -0500 |
---|---|---|
committer | Michael Larabel <michael@phx-laptop.(none)> | 2008-12-04 15:07:07 -0500 |
commit | de3623e4dd35d95ec12a4e2f0a8e70c43e56f87f (patch) | |
tree | d7f879c6e6ded986184a0f55cdd5963543afd0f2 /pts-core/functions/pts-functions_shell.php | |
parent | 8d96c2e1e86851ff0c11494c5a550ee67c77cab2 (diff) | |
download | phoronix-test-suite-upstream-de3623e4dd35d95ec12a4e2f0a8e70c43e56f87f.tar.gz phoronix-test-suite-upstream-de3623e4dd35d95ec12a4e2f0a8e70c43e56f87f.tar.xz phoronix-test-suite-upstream-de3623e4dd35d95ec12a4e2f0a8e70c43e56f87f.zip |
pts-core: Add pts-functions_io.php and pts-functions_global.php
Diffstat (limited to 'pts-core/functions/pts-functions_shell.php')
-rw-r--r-- | pts-core/functions/pts-functions_shell.php | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/pts-core/functions/pts-functions_shell.php b/pts-core/functions/pts-functions_shell.php index 7d8da30..5446bbb 100644 --- a/pts-core/functions/pts-functions_shell.php +++ b/pts-core/functions/pts-functions_shell.php @@ -235,5 +235,44 @@ function pts_process_running_string($process_arr) return $p_string; } +function pts_process_register($process) +{ + // Register a process as active + if(!is_dir(TEST_ENV_DIR)) + { + mkdir(TEST_ENV_DIR); + } + if(!is_dir(TEST_ENV_DIR . ".processes")) + { + mkdir(TEST_ENV_DIR . ".processes"); + } + + return file_put_contents(TEST_ENV_DIR . ".processes/" . $process . ".p", getmypid()); +} +function pts_process_remove($process) +{ + // Remove a process from being active, if present + return is_file(TEST_ENV_DIR . ".processes/" . $process . ".p") && @unlink(TEST_ENV_DIR . ".processes/" . $process . ".p"); +} +function pts_process_active($process) +{ + // Register a process as active + $active = false; + if(is_file(TEST_ENV_DIR . ".processes/" . $process . ".p") && !IS_SOLARIS) + { + $pid = trim(@file_get_contents(TEST_ENV_DIR . ".processes/" . $process . ".p")); + $ps = trim(shell_exec("ps -p $pid 2>&1")); + + if(strpos($ps, "php") > 0) + { + $active = true; + } + else + { + pts_process_remove($process); + } + } + return $active; +} ?> |