From: Peter Palfrader Date: Tue, 25 Dec 2007 18:39:37 +0000 (+0100) Subject: ud-fingerserv: correctly daemonize X-Git-Tag: userdir-ldap-0.3.16~31 X-Git-Url: https://git.adam-barratt.org.uk/?a=commitdiff_plain;h=d4a997d26389bda47177215bcd41a3ae1abbffa5;hp=340801790a3e8d042149a48d4eff19dc863dff0a;p=mirror%2Fuserdir-ldap.git ud-fingerserv: correctly daemonize Also fork() a second time after running setsid(). --- diff --git a/ud-fingerserv b/ud-fingerserv index 42b8239..1c977d8 100755 --- a/ud-fingerserv +++ b/ud-fingerserv @@ -61,9 +61,12 @@ if (!$use_inetd) { 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: $!"; + my $pid; + defined($pid = fork) or die "Can't fork: $!"; exit if $pid; setsid or die "Can't start a new session: $!"; + defined($pid = fork) or die "Can't fork: $!"; + exit if $pid; open STDERR, '>&STDOUT' or die "Can't dup stdout: $!"; }