in reply to waiting until a file updates...
You could have the child hold a lock on the file. Have the parent try to get the lock after noticing that the child has touched it through stat. The blocking flock call will effectively sleep until it obtains the lock. The -M $file test operator may be tidier than direct use of stat.
use Fcntl qw(:flock); #... # Child does { open my $foo, '+<', $file or die $!; flock $foo, LOCK_EX | LOCK_NB or die $!; # Reading and Writing close $foo or die $!; } # child goes on... # Parent does sleep 1 while 1 < -M $file; { open my $foo, '<', $file or die $!; flock $foo, LOCK_EX or die $!; sleep 1; unless (kill 0, $child_pid) { # close file, restart child, and redo } # do stuff close $foo or die $!; }
The child uses non-blocking flock to break the narrow race window between parent and child, occuring between open and flock.
Alternatively, you could have the child raise a signal when it's done.
After Compline,
Zaxo
|
|---|