in reply to Re^4: why won't the hash go away?
in thread why won't the hash go away?
I did take the excellent advice presented here. My code now "uses memory management via fork".
while(1) { if (my $pid = fork) { open F, ">>run.log" or die "Can't open log file: $!"; print F scalar(localtime(time)), " Launched process to play cards. +\n"; my ($user,$system,$cuser,$csystem) = times; print F "user $user system $system children $cuser, $csystem\n"; close F; waitpid($pid, 0); open F, ">>run.log" or die "Can't open log file: $!"; print F scalar(localtime(time)), " Child process finished.\n"; my ($user,$system,$cuser,$csystem) = times; print F "user $user system $system children $cuser, $csystem\n"; close F; } else { die "Cannot fork: $!" unless defined $pid; initialize(); while ($current < $MAXMETRIC) { goodbye('INT') if -e $DIEFILE; ## etc } ## end while ($current < $MAXMETRIC) } }
The "Child process finished" is after the waitpid, so that should mean that my kid is dead. There is a caveat on times() that says "times for children are included only after they terminate" which should have occurred. Why didn't I see any value on the line for 16:29:34 (and similarly for 16:29:35). Is this some sort of race condition? Or is my OS (oh, look at the Vista out this window!) so brain dead that the feature isn't implemented?Mon Jan 14 12:36:28 2008 Launched process to play cards. user 0.031 system 0.031 children 0, 0 Mon Jan 14 16:29:34 2008 Child process finished. user 9774.546 system 556.765 children 0, 0 Mon Jan 14 16:29:35 2008 Launched process to play cards. user 9774.546 system 556.781 children 0, 0
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^6: why won't the hash go away?
by BrowserUk (Patriarch) on Jan 14, 2008 at 22:31 UTC | |
by WoodyWeaver (Monk) on Jan 14, 2008 at 23:23 UTC |