summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: a1a3d31)
raw | patch | inline | side by side (parent: a1a3d31)
author | psc <psc@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Fri, 11 Mar 2011 15:34:15 +0000 (15:34 +0000) | ||
committer | psc <psc@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Fri, 11 Mar 2011 15:34:15 +0000 (15:34 +0000) |
Cleanup gosa-si-server forking behaviour
git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.6-lhm@20618 594d385d-05f5-0310-b6e9-bd551577e9d8
git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.6-lhm@20618 594d385d-05f5-0310-b6e9-bd551577e9d8
trunk/gosa-si/gosa-si-server | patch | blob | history |
index c79bfdd1c9297b919b8121f3477987557619fb61..18723f8b2213841d3601acc356437ba43866cc94 100755 (executable)
$SIG{CHLD} = 'IGNORE';
-# forward error messages to logfile
-if( ! $foreground ) {
- open( STDIN, '+>/dev/null' );
- open( STDOUT, '+>&STDIN' );
- open( STDERR, '+>&STDIN' );
-}
-
# Just fork, if we are not in foreground mode
if( ! $foreground ) {
- chdir '/' or die "Can't chdir to /: $!";
+ if (! chdir('/')) {
+ daemon_log("Can't chdir to /: $!", 1);
+ exit( 1 );
+ }
+ umask( 0 );
$pid = fork;
- setsid or die "Can't start a new session: $!";
- umask 0;
} else {
$pid = $$;
}
-# Do something useful - put our PID into the pid_file
if( 0 != $pid ) {
+ # Parent: put PID into the $pid_file
open( LOCK_FILE, ">$pid_file" );
print LOCK_FILE "$pid\n";
close( LOCK_FILE );
if( !$foreground ) {
- exit( 0 )
- };
+ exit( 0 );
}
+}
+else {
+ # Child
+ open( STDIN, '+>/dev/null' );
+ open( STDOUT, '+>&STDIN' );
+ open( STDERR, '+>&STDIN' );
+ if (! POSIX::setsid()) {
+ daemon_log("Can't start a new session: $!");
+ exit( 1 );
+ }
+ $poe_kernel->has_forked() if ($poe_kernel->can('has_forked'));
+}
+
# parse head url and revision from svn
my $server_status_hash = { 'developmental'=>'revision', 'stable'=>'release'};