Longhorn PHP 2025 - Speakers and Schedule Announced!

Voting

: max(six, nine)?
(Example: nine)

The Note You're Voting On

gabe at fijiwebdesign dot com
15 years ago
Based on what james at voodoo dot co dot uk said, but modified for CLI scripts (ie: there is no $_SERVER).

<?php

/**
* Check for a current process by filename
* @param $file[optional] Filename
* @return Boolean
*/
function processExists($file = false) {

$exists = false;
$file = $file ? $file : __FILE__;

// Check if file is in process list
exec("ps -C $file -o pid=", $pids);
if (
count($pids) > 1) {
$exists = true;
}
return
$exists;
}

?>

<< Back to user notes page

To Top