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?
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.