in reply to RE: Re: Getting Close and Cuddly with the sleep() function
in thread Getting Close and Cuddly with the sleep() function

if(fork()) doesn't mean "if fork worked": :)))
it means if fork return a true value (the pid of the child process) then i'm the parent and i have to print my html else i'm the children (fork return 0) and i have to send the email. see "perldoc -f fork" for more info (and some hints on how andle errors)
fork is a unix system call (see fork(2)) but recent versions of perl try to implement it on windows too
for the second question: if you pipe your info to another script you have to wait for the second script to finish (unless you fork before the pipe :-)
  • Comment on RE: RE: Re: Getting Close and Cuddly with the sleep() function

Replies are listed 'Best First'.
RE: RE: RE: Re: Getting Close and Cuddly with the sleep() function
by skazat (Chaplain) on Nov 06, 2000 at 06:01 UTC

    I see,

    wait, no, hold on. Where do you actually call the fork() function? Or how do you actually fork something into a child process? Thanks for the info on where to look for the correct documentation :) -justin simoni
    !skazat!

      when you call the fork function ("if(fork())" does this) the current process get duplicated and the 2 processes keep running from the point where you called fork.
      now the only way you have to know if you are the parent or the child process is to test the exit status of fork() (here cames if(fork()) )
      fork return 0 to the child and the pid of the child to the parent (!=0 then true) so you put the code for the parent in the if block and the code for the child in the else block...

      please look at "perldoc -f fork" for more info.