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??
The direct answer to your question is that the filehandles which form the connection to the web client get duplicated in the child, so the connection doesn't get closed until both the parent and child have closed the filehandles. So normally the parent would fork, the child would immediately close any filehandles it shares with the parent, then go off and do its thing. In the meantime the parent handles doing any HTML output then quits.

Note that you show both the parent and child outputting the headers, which is wrong.

But more generally this arrangement is likely to be a bad idea. It's very easy for someone to maliciously or inadvertently send many short requests to the web server, which results in thousands of long-running forked processes vying for memory and CPU.

Dave.


In reply to Re: Can I have a Perl script, initiated from a browser, fork itself, and not wait for the child to end? by dave_the_m
in thread Can I have a Perl script, initiated from a browser, fork itself, and not wait for the child to end? by bartender1382

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: (5)
As of 2024-04-15 02:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found