The problem is that perl is wait()ing for the daemon to return before exiting.
>From man perlipc: Complete Dissociation of Child from Parent In some cases (starting server processes, for instance) you'll want to completely dissociate the child process from the parent. This is often called daemonization. A well behaved daemon will also chdir() to the root direc tory (so it doesn't prevent unmounting the filesystem con taining the directory from which it was launched) and redirect its standard file descriptors from and to /dev/null (so that random output doesn't wind up on the user's terminal). use POSIX 'setsid'; sub daemonize { chdir '/' or die "Can't chdir to /: $!"; open STDIN, '/dev/null' or die "Can't read /dev/null: $!"; open STDOUT, '>/dev/null' or die "Can't write to /dev/null: $!"; defined(my $pid = fork) or die "Can't fork: $!"; exit if $pid; setsid or die "Can't start a new session: $!"; open STDERR, '>&STDOUT' or die "Can't dup stdout: $!"; } The fork() has to come before the setsid() to ensure that you aren't a process group leader (the setsid() will fail if you are). If your system doesn't have the setsid() function, open /dev/tty and use the "TIOCNOTTY" ioctl() on it instead. See tty(4) for details. Non-Unix users should check their Your_OS::Process module for other solutions. ---------------------------------------------------------------------- Andrew J Perrin - http://www.unc.edu/~aperrin Assistant Professor of Sociology, U of North Carolina, Chapel Hill [EMAIL PROTECTED] * andrew_perrin (at) unc.edu On Fri, 8 Aug 2003, Henning Moll wrote: > Hi! > > I use a perl cgi script to start a daemon via http-request: > > > ---ttt.pl--- > [...] > system("daemon &"); > [...] > print "<html> ... </html>"; > ---ttt.pl--- > > starting of the daemon works, but the http-request is never answered > completley (That means, the browser is waiting for more data forever...). > > The cgi process is not finished, a 'ps -aecf' shows > > www-data 12011 12010 - 30 01:14 ? 00:00:00 [ttt.pl] <defunct> > > Hmm, <defunct>, what does that mean? How to start the daemon the right way? > > Best regards > Henning > > > -- > To UNSUBSCRIBE, email to [EMAIL PROTECTED] > with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED] > > -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]