Ian the Terrible has asked for the wisdom of the Perl Monks concerning the following question:
There are plenty of "or die" and "or warn" clauses in the real code, so I'll know if something fails. What bothers me is that closing sequence. It's possible that $my_file could get written to after it gets unlocked, and then vanish when it gets unlinked. Is there a better way to handle this kind of thing?open (FILE, $my_file); flock FILE, 2; #exclusive lock #Parse file and do various things with the content. flock FILE, 8; # unlock close ( FILE ); unlink $my_file;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Avoiding a race condition
by c-era (Curate) on May 19, 2000 at 04:16 UTC | |
by ZZamboni (Curate) on May 19, 2000 at 05:37 UTC | |
by takshaka (Friar) on May 19, 2000 at 06:10 UTC | |
by ZZamboni (Curate) on May 19, 2000 at 08:18 UTC | |
|
Re: Avoiding a race condition
by takshaka (Friar) on May 19, 2000 at 06:32 UTC | |
|
Re: Avoiding a race condition
by Ian the Terrible (Beadle) on May 19, 2000 at 11:37 UTC | |
|
Re: Avoiding a race condition
by Anonymous Monk on May 19, 2000 at 11:28 UTC |