Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Make a perl script self aware... all platforms

by monkeyperl (Initiate)
on Jun 25, 2008 at 00:51 UTC ( [id://693855]=note: print w/replies, xml ) Need Help??


in reply to Answer: Re: Make a perl script self aware...
in thread Make a perl script self aware...

This is an interesting problem indeed.
I have used this method of opening the script itself and placing an exclusive lock on it for quite sometime, without problems

However, I have started working with Unix AIX recently and the solution no longer works :(

I had never had any problems with several Linux distros, FreeBSD, Mac OS X or Windows.

But sadly under AIX the script fails to get a lock on itself, weather it is running or not.

I added a $! to the flock like so:
flock LH, LOCK_EX|LOCK_NB or die "$0 is already running somewhere!\n$!";

and the OS error message is:
A file descriptor does not refer to an open file

Interesting, the error message reads as if the file open failed,
and yet it was fine as far as I can tell because the 'or die' for open did not get invoked... odd.

Any suggestions?

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (9)
As of 2024-04-23 11:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found