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 <h...@suse.de> --- usr/iscsid.c | 16 ++++++++-------- usr/log.c | 6 ++++-- 2 files changed, 12 insertions(+), 10 deletions(-) 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); + } } -- 1.7.3.4 -- You received this message because you are subscribed to the Google Groups "open-iscsi" group. To post to this group, send email to open-iscsi@googlegroups.com. To unsubscribe from this group, send email to open-iscsi+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/open-iscsi?hl=en.