http://qs321.pair.com?node_id=1034338


in reply to Re^3: Creating a perl daemon
in thread Creating a perl daemon

This always works for me.
daemonize(); 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: $!"; }
I found it by googling.
Suyash Jain suyash@linuxhacks.in http://www.LinuxHacks.in A Blog for Every Windows User,FEEL THE Linux freedom To RULE THE BOX.