in reply to Re: Re: File Locking
in thread File Locking
There is a way to check if the file is locked from another script but you can't safely delete it because as soon as you close the file, so that you can delete it, it will be unlocked and there is a slight chance that some other process will write to it in the interim.open STDOUT, ">>$dir/TEST.NEW" or exit 1; open STDERR, ">>&STDOUT" or exit 2; flock STDOUT, LOCK_EX | LOCK_NB or exit 3; truncate STDOUT, 0; # delete everything from the file # The remainder of the program will be writing to an # empty file. close STDERR; close STDOUT;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: Re: File Locking
by nimdokk (Vicar) on Apr 23, 2003 at 18:26 UTC |