note 103789 added to function.posix-getpgid

From: Date: Tue, 03 May 2011 22:46:48 +0000
Subject: note 103789 added to function.posix-getpgid
Groups: php.notes 
Request: Send a blank email to php-notes+get-179390@lists.php.net to get a copy of this message
This function and posix_getsid can be used to check if a process is alive (since they return FALSE if the process can not be found) So if you have a PID in a lock file, and you want to know if that process is still running- you can use this code: $lockfile = sys_get_temp_dir() . '/myScript.lock'; $pid = file_get_contents($lockfile); if (posix_getsid($pid) === false) { print "process has died! restarting...\n"; file_put_contents($lockfile, getmypid()); // create lockfile } else { print "PID is still alive! can not run twice!\n"; exit; } :-) perfect if you need to make sure a cron job or shell script has ended before it can be started again. ---- Server IP: 69.147.83.197 Probable Submitter: 68.49.191.190 ---- Manual Page -- http://www.php.net/manual/en/function.posix-getpgid.php Edit -- https://master.php.net/note/edit/103789 Del: integrated -- https://master.php.net/note/delete/103789/integrated Del: useless -- https://master.php.net/note/delete/103789/useless Del: bad code -- https://master.php.net/note/delete/103789/bad+code Del: spam -- https://master.php.net/note/delete/103789/spam Del: non-english -- https://master.php.net/note/delete/103789/non-english Del: in docs -- https://master.php.net/note/delete/103789/in+docs Del: other reasons-- https://master.php.net/note/delete/103789 Reject -- https://master.php.net/note/reject/103789 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#179390) next »