Package: backuppc
Version: 2.1.0-10
Severity: normal
Tags: patch

backuppc does not properly detach when starting.  A symptom of this is
that if you ssh [EMAIL PROTECTED]; /etc/init.d/backuppc restart; and
then try to logout, your ssh session hangs.

This patch makes backuppc detach properly.  Also see
http://www.erlenstar.demon.co.uk/unix/faq_2.html#SEC16

--- /usr/share/backuppc/bin/BackupPC.orig       2005-03-23 17:07:24.000000000 
+0100
+++ /usr/share/backuppc/bin/BackupPC    2005-03-23 17:18:16.000000000 +0100
@@ -66,6 +66,7 @@
 use Socket;
 use Carp;
 use Digest::MD5;
+use POSIX qw(setsid);
 
 ###########################################################################
 # Handle command line options
@@ -262,8 +263,16 @@
         #
         # daemonize by forking
         #
-        defined(my $pid = fork) or die "Can't fork: $!";
-        exit if $pid;   # parent exits
+        my $pid;
+        defined($pid = fork) or die "Can't fork: $!"; exit if $pid;   # parent 
exits
+        POSIX::setsid();
+        defined($pid = fork) or die "Can't fork: $!"; exit if $pid;   # parent 
exits
+        chdir ("/") or die ("Cannot chdir to /: $!\n");
+        close(STDIN);  open (STDIN , ">/dev/null") or die ("Cannot open 
/dev/null as stdin\n");
+        # STDOUT and STDERR are handled in LogFileOpen() right below,
+        # otherwise we would have to reopen them too.
+        #close(STDOUT); open (STDOUT, ">/dev/null") or die ("Cannot open 
/dev/null as stdout\n");
+        #close(STDERR); open (STDERR, ">/dev/null") or die ("Cannot open 
/dev/null as stderr\n");
     }
 
     #


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to