Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

Where did you find the code example you posted? I looked at the written example documentation on cpam and didnt see that version of the code. At any rate I typed in your code and ran it. The PID returned from the fork manager and the PID listed by the system 'top' cmd matched. So I started looking of issues with my specific code. So after investigating my code, I think I have located the issue. I am not sure I have the knowledge to fully explain the technical cause of the issue, but hopefully someone else reading can and will explain.

In your code example, if you replace the line... while () {}; # ie the work item for the child process which in this case is just a forever loop.

replace with .... system("foreverLoop.pl"); # here the foreverLoop.pl file contains the same while() {} code.

and run... you will see the +1 offset in PIDs.

In general my code is attempting to use the forkManager to submit jobs by running external scripts(pl, ksh, etc), so I am using the perl 'system' cmd to start those task. The introduction of the system cmd is causing the PID reported by the forkManager to be 1 less than the PID tracked by the top cmd.

I should have expected this since system probably starts it's own child process. However having said all that I am really not sure how to properly work around this. Is it safe for me to just change the reported PID by +1 or is there a better way? I am just not sure if the +1 offset is a for sure thing or if the actual offset is subject to system timing?


In reply to Re^3: forkManager PID 1 less than top by MAR99
in thread forkManager PID 1 less than top by MAR99

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 sharing their wisdom with the Monastery: (3)
As of 2024-04-25 23:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found