Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: Is the program there? (W32)

by Thelonius (Priest)
on Mar 23, 2006 at 22:40 UTC ( [id://538894]=note: print w/replies, xml ) Need Help??


in reply to Is the program there? (W32)

Searching through ps output is not really the right way to do it on Unix. It's time-consuming and error-prone--someone may create a link to the program with a different name or there may be two different programs with the same name.

Fortunately there's a simple solution that works on Unix and Windows:

#!perl -w use strict; use Fcntl qw(LOCK_EX LOCK_NB); my $lockfile = "/someabsolutepath/writeabledirectory/lockfile"; open LOCKFILE, ">", $lockfile or die "Cannot open lockfile\n"; if (!flock(LOCKFILE, LOCK_EX|LOCK_NB)) { print STDERR "Another copy of application is already running\n"; exit(0); }

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://538894]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (7)
As of 2024-04-16 18:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found