Re: Unique process on Win32?
| From: | Leif K-Brooks | Date: | Fri, 09 May 2003 00:23:38 +0000 |
| Subject: | Re: Unique process on Win32? | ||
| References: | 1 | Groups: | php.gtk.general |
| Request: | Send a blank email to php-gtk-general+get-3386@lists.php.net to get a copy of this message | ||
$program = 'Foo';
function unlock(){
unlink('.lock'.$GLOBALS['program']);
}
if(file_exists('.lock'.$program)){
die('Only one instance can be opened at a time!');
}else{
fopen('.lock'.$program,'w');
register_shutdown_function('unlock');
}
Benjamin Smith wrote:
What's a good way to make sure that there's one (and only one) instance of a program running on Win32? I've tried opening a lock file, hoping that multiple fopen() would cause an error or something I can trap. So far, no errors. Any ideas?-- The above message is encrypted with double rot13 encoding. Any unauthorized attempt to decrypt it will be prosecuted to the full extent of the law.