in reply to (tye)Re: Temporary files and cleaning up after an interruption
in thread Temporary files and cleaning up after an interruption
How does a child wait for a parent to exit? (use flock as an IPC mechanism)That's nice. Thanks for the idea.
Here's an alternative mechanism. I think this might be more commonly used:
I used this technique extensively in my obfuscated contest entry.#!/usr/bin/perl pipe R, W or die; die unless defined my $pid = fork; if ($pid) { # parent close R; print "parent: I'm going to do some work now\n"; for (1 .. rand 12) { print "Parent is working...\n"; sleep 1; } print "parent: exiting\n"; } else { # child close W; print "child: waiting for parent to exit\n"; <R>; print "child: parent exited; exiting\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Temporary files and cleaning up after an interruption
by Dominus (Parson) on Jan 05, 2001 at 08:45 UTC | |
by tye (Sage) on Jan 05, 2001 at 10:23 UTC |