[Pkg-iscsi-maintainers] [SCM] Debian Open-iSCSI Packaging branch, upstream-mnc, updated. 2.0-872-193-gde2c0e7

Mike Christie michaelc at cs.wisc.edu
Sat Apr 7 15:43:21 UTC 2012


The following commit has been merged in the upstream-mnc branch:
commit e5bd9130d5d35cbdce04f04e156bde82a0641583
Author: Hannes Reinecke <hare at suse.de>
Date:   Tue Jun 21 11:23:02 2011 +0200

    iscsid sends SIGTERM to PID 0
    
    Occasionally iscisd will send a SIGTERM to pid 0, causing
    all sorts of weird things. Problem is that pid == 0 is
    a valid return value for log_init(), so that all routines
    only check for pid < 0. However, as the signal handler
    is inherited from the parent, even the logging thread
    has a signal handler installed, for which the internal
    pid is always '0'. So when a SIGTERM is send to the
    logging thread, it'll forward the signal to PID 0.
    
    References: bnc#589064
    
    Signed-off-by: Hannes Reinecke <hare at suse.de>

diff --git a/usr/iscsid.c b/usr/iscsid.c
index 67a6944..3fa3295 100644
--- a/usr/iscsid.c
+++ b/usr/iscsid.c
@@ -339,14 +339,6 @@ int main(int argc, char *argv[])
 	int control_fd;
 	pid_t pid;
 
-	/* do not allow ctrl-c for now... */
-	sa_new.sa_handler = catch_signal;
-	sigemptyset(&sa_new.sa_mask);
-	sa_new.sa_flags = 0;
-	sigaction(SIGINT, &sa_new, &sa_old );
-	sigaction(SIGPIPE, &sa_new, &sa_old );
-	sigaction(SIGTERM, &sa_new, &sa_old );
-
 	while ((ch = getopt_long(argc, argv, "c:i:fd:u:g:p:vh", long_options,
 				 &longindex)) >= 0) {
 		switch (ch) {
@@ -390,6 +382,14 @@ int main(int argc, char *argv[])
 	if (log_pid < 0)
 		exit(ISCSI_ERR);
 
+	/* do not allow ctrl-c for now... */
+	sa_new.sa_handler = catch_signal;
+	sigemptyset(&sa_new.sa_mask);
+	sa_new.sa_flags = 0;
+	sigaction(SIGINT, &sa_new, &sa_old );
+	sigaction(SIGPIPE, &sa_new, &sa_old );
+	sigaction(SIGTERM, &sa_new, &sa_old );
+
 	sysfs_init();
 	if (idbm_init(iscsid_get_config_file)) {
 		log_close(log_pid);
diff --git a/usr/log.c b/usr/log.c
index 9d5f933..5747554 100644
--- a/usr/log.c
+++ b/usr/log.c
@@ -474,6 +474,8 @@ void log_close(pid_t pid)
 		return;
 	}
 
-	kill(pid, SIGTERM);
-	waitpid(pid, &status, 0);
+	if (pid > 0) {
+		kill(pid, SIGTERM);
+		waitpid(pid, &status, 0);
+	}
 }

-- 
Debian Open-iSCSI Packaging



More information about the Pkg-iscsi-maintainers mailing list