in reply to File Locking
2. You're redirecting STDOUT and STDERR and then using die(), which will clobber your TEST.NEW if flock() fails. Either don't use die() and just exit() or implement a logging mechanism of some sort so that you're not writing to STDOUT/STDERR.use Fcntl ':flock'; ... flock $fh, LOCK_EX or exit $status; ...
--perlplexer# will block until file is unlocked flock $fh, LOCK_EX or exit $status; # will exit immediately if the file is locked flock $fh, LOCK_EX | LOCK_NB or exit $status;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: File Locking
by nimdokk (Vicar) on Apr 23, 2003 at 16:44 UTC | |
by perlplexer (Hermit) on Apr 23, 2003 at 17:55 UTC | |
by nimdokk (Vicar) on Apr 23, 2003 at 18:26 UTC |