in reply to Disappearing File
Your attempt at making a semaphore file is not having any effect. The race condition caused by reading and writing separately goes like this:
| Process A | Process B | |
| 1 | readdata() | |
| 2 | readdata() | |
| 3 | writedata() | |
| 4 | writedata() |
You should open the file once to read and write, flock it (blocking), read, process, and write. Close releases the lock.
To use a semaphore file, you should do a blocking sysopen with O_EXCL, and unlink the file when you're done. There's no need to use both methods.
I think you also have a problem with autovivifying globals in your subroutines, then expecting later lexicals to appear in their place. use warnings; use strict;.
After Compline,
Zaxo
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Disappearing File
by Gorby (Monk) on Jan 13, 2004 at 03:11 UTC | |
by Zaxo (Archbishop) on Jan 13, 2004 at 03:47 UTC |