From: janw Date: Mon, 14 Jan 2008 13:28:05 +0000 (+0000) Subject: Added some "daemonize" stanzas X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=5e09e958689ad06b082821299940196c232eea29;p=gosa.git Added some "daemonize" stanzas git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@8323 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/gosa-si/gosa-si-bus b/gosa-si/gosa-si-bus index 330d205a9..bca785bfe 100755 --- a/gosa-si/gosa-si-bus +++ b/gosa-si/gosa-si-bus @@ -1263,7 +1263,17 @@ daemon_log(" ", 1); daemon_log("$0 started!", 1); # Just fork, if we"re not in foreground mode -if( ! $foreground ) { $pid = fork(); } +if( ! $foreground ) { + 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: $!"; + open STDERR, '>>/dev/null' or die "Can't write to /dev/null: $!"; + defined($pid = fork) or die "Can't fork: $!"; + exit if $pid; + setsid or die "Can't start a new session: $!"; + umask 0; +} + else { $pid = $$; } # Do something useful - put our PID into the pid_file diff --git a/gosa-si/gosa-si-server b/gosa-si/gosa-si-server index 8f2b3f3c6..807f86a85 100755 --- a/gosa-si/gosa-si-server +++ b/gosa-si/gosa-si-server @@ -919,7 +919,14 @@ daemon_log("$0 started!", 1); # Just fork, if we"re not in foreground mode if( ! $foreground ) { - $pid = fork(); + 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: $!"; + open STDERR, '>>/dev/null' or die "Can't write to /dev/null: $!"; + defined($pid = fork) or die "Can't fork: $!"; + exit if $pid; + setsid or die "Can't start a new session: $!"; + umask 0; } else { $pid = $$; } @@ -980,7 +987,6 @@ while( my ($mod_name, $info) = each %$known_modules ) { #} # - ################################## #everything ready, okay, lets start ##################################