Hi, Can you help me understand the below a little better.
As I understand what's going on, the Process (let's say PID=100) spawns a child with the fork() function (let's say PID=200). This (200) is assigned to $pid in the parent, and zero (0) is assigned to $pid in the child. So, what does "my $pid=fork()" resolve to in each case? I'll assume that it resolves to the PID that fork returns. So, in the parent, the statement resolves to 200 and the unless statement doesn't resolve. In the child, the statement resolves to 0 and the unless statement DOES resolve. So, the parent prints a message to STDOUT and quits, while the child keeps on running (in the little do/while loop) doing that stuff that's in there :) Ok ... so, um, why go through all this? Why not just write your do/while block and just execute it in the background on the command line? is fork() doing something else that helps a daemon that I'm not aware of? --Errin On Sat, 21 Aug 2004 09:53:23 -0400, Adam Rosi-Kessel <[EMAIL PROTECTED]> wrote: <<SNIP>> > > Here's the skeleton of it: > > ---- > unless (my $pid = fork()) { > do { > &SendEmailToUsers; > sleep 3 * 24 * 60 * 60; > } while (1); > } > > print "Starting email daemon...\n"; > ----- > > That's all. This will run indefinitely, and every three days run the > subroutine SendEmailToUsers. You obviously need to add a lot more to <<SNIP>> -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>