I have a system that currently has 5-6 Perl daemons running on it 24/7. This system has 2 GB, multi-core, and 4 GB of RAM.

I am working on a different version of this system that will be running on a 500 Mhz 500 MB system (a Soekris Net5501, if knowing the system makes a difference). Both systems are Debian Linux based.

From my limited understanding, if I use fork(), both the parent and child process are running within the same instance of Perl in memory. I remember experimenting with this previously and having to kill zombie processes, but I don't see them remaining anymore after a child thread is killed on my current systems. (Which are running later versions of both Linux and Perl than what I started on.) This is without using $SIG{CHILD} = 'IGNORE'.

I'd like to be able to use one instance of Perl to run all the daemons on the newer system. The ones on the new system will be smaller and have less to do than the ones on the big computer. But I have three main questions about this.

1) On the other system I would create a batch file that was an endless loop. In the loop it'd run the daemon, that way if the daemon was killed, it'd loop back through and run it again. I've seen a number of programs do this. But on Perl, unless I want to keep dealing with zombies, is there a way to tell when a child process has quit?

2) Regarding zombies: Was there some improved coding somewhere or a change in how things are handled in Linux? I don't see zombies showing up when I run tests now.

3) If I use one instance of Perl and fork off a number of child processes instead of running multiple instances of Perl, will that change the priority for the forked processes, or will they likely get the same kind of treatment or CPU time as they would have if I ran them as separate processes?

Thanks for any information on this. I've been Googling, but have yet to find information on this that's clear to me or can tell me why I don't see zombies now when I test fork() and kill off the child processes.


In reply to Forking vs. A New Process by HalNineThousand

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.