Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
I haven't seen the problem you describe, oddly enough. That might be OS / version specific. My routines in the past would exit because of time or state limits exceeded (I'd have them start over after four hours or four billion states examined) or signals (I'd have them print and die if I sent them an INT or HUP). They would exit quickly and normally on the latter (some flavor of linux and ActiveState, 5.8.something.)

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) } }
A run shows the following:
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
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?

In reply to Re^5: why won't the hash go away? by WoodyWeaver
in thread why won't the hash go away? by WoodyWeaver

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (1)
As of 2024-04-25 01:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found