Hi Again,

That works great!
But there is one small problem.

A quick run down of what i'm doing.
I've created a simple webserver (mainly because Apache can't execute root commands, but thats another story).
So, i have this:
#START MY LISTENING DAEMON WITH HTTP::DAEMON

# Fork to begin with so that it can run from 
# shell in the background
my $mainpid = fork;
  if(!$mainpid)
  {
     while ($new_sock = $sock->accept()) {
     # Theres a connection, fork it so that that user 
     # has there own dedicated process
     
      my $pid = fork; 
       if(!$pid)
         { 
       while (my $request_obj = $new_sock->get_request()) {
        #This is a new HTTP header, and is basically a 
        #request for a page
        #Fork again

           my $pid2 = fork;
           if(!$pid2) {

             #RETURN THE PAGE 

                      exit; #This kill $pid 
                      }

        	} #End reading the object
	exit; #Kill the child
       }#End Fork2	

     } #End Accept Request
    } # End the main fork

This code works fine. The problem is, it leaves behind lots of these:
root 5066 0.0 0.0 0 0 pts/1 Z 21:33 0:00 perl <defunct>
What's causing it?

In reply to Re^2: Forking by andy7t
in thread Forking by andy7t

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.