Hi everyone!

Most of you are probably familiar with perlipc and, specifically, the "Complete dissociation of child from parent" section of it.
I myself used the code from that page a few times thinking that it does indeed completely detach child from parent. Until today that is.
If my understanding of what setsid() is supposed to do is correct, as soon as it gets called and returns 'true', parent process should no longer see the process that called setsid() as child.
Consider the fragment of code below.
daemon(); sub daemon{ # Create a daemon which does nothing but "sleep 100" my $dpid = fork(); return 0 unless defined $dpid; unless ($dpid){ exit 255 unless open STDIN, '/dev/null'; exit 255 unless open STDOUT, '>/dev/null'; exit 255 unless open STDERR, '>/dev/null'; exit 255 unless setsid(); sleep 100; exit 0; } return 0 unless wait() == -1; return $dpid; }
On HPUX 11, Perl 5.6.1, this sub wait()s for the daemon to finish as if it was still a normal child process. And I know that setsid() succeeded since parent keeps wait()ing for 100 seconds.
So, what is this? A feature? Is this how setsid() is supposed to work? Or should I not work on Sundays and get more sleep?

--perlplexer

In reply to setsid() and complete (?) dissociation of child from parent by perlplexer

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.