in reply to fork() && exit;

...when I saw your initial code, I thought I could see what was going wrong, based upon my guess about your intention. And that has been well addressed.

What also occurred to me is that there is a good reason to use the "fork && exit" approach you started with. I've seen this well used in the creation of a bare-bones web server written in Perl.

The algorithm worked like this:

*) Parse command-line and exit if there are errors *) Read config file and exit if there are errors *) fork && exit # so that the... Parent dies Child continues in background acting as a server

...to put it another way, it's a cheap approach to backgrounding a server (or daemon) process.

I didn't get that this was something you wanted to do, but you might want to experiment with that approach to see what it does for you. Taking into account the other things that have been explained here, you might find that this adds another tool to your bag 'o tricks.

So that you get a complete understanding of the experiment, you will want to observe the processes that get created and ask yourself a few questions.

Have some fun with the variations in this strategy and decide whether this will serve you in one of your future programming tasks. But mostly have fun!

...All the world looks like -well- all the world, when your hammer is Perl.
---v