Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
i wrote this a short while back as i started down the path of trying to understand wait. i think i've got a pretty good handle on how it works, and the idea that you really need to wait for each child process, or at least until they all close. in a response to my previous post, bluto offers a suggestion on how to handle the problem by incrementing a variable for each child process spawned and then waiting in a while loop as the variable is decremented. That makes sense to me, or at least the "how it works" makes sense.
I found this code, which seems to work as well, and really does not let the parent pid exit until all children are through as evidenced by the command line not returning until all children run through. however i'm not really certain just *how* it works

## wait on chid processes to exit while (wait() != -1) { return 1 if ($?); }

i see that return will return a value of 1 if there is a child process error held in $?, however the condition of the while is what confuses me. wait not equal to -1. so in one line its waiting, but checking on a value, and i am not sure where the value is coming from.

mad thanks! -c


In reply to what is this doing? - while (wait() != -1) by c

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 surveying the Monastery: (3)
As of 2024-04-20 13:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found