diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2007-01-24 02:35:42 +0000 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2007-01-24 02:35:42 +0000 |
commit | 2d77a5240c9781bcd07dd761eae4df7a474dddb3 (patch) | |
tree | a74e83aa263b91462ceff9aa10ed18a3d4b5c208 /gacopyz | |
parent | fbc9b24091647e118de4df712105f3e6c19d30f4 (diff) | |
download | mailfromd-2d77a5240c9781bcd07dd761eae4df7a474dddb3.tar.gz mailfromd-2d77a5240c9781bcd07dd761eae4df7a474dddb3.tar.bz2 |
(gacopyz_cleanup_conn): Print debugging message; Do not display spurious 'signal 15' messages
git-svn-id: file:///svnroot/mailfromd/trunk@1238 7a8a7f39-df28-0410-adc6-e0d955640f24
Diffstat (limited to 'gacopyz')
-rw-r--r-- | gacopyz/proc.c | 30 |
1 files changed, 21 insertions, 9 deletions
diff --git a/gacopyz/proc.c b/gacopyz/proc.c index f919770d..5df987e1 100644 --- a/gacopyz/proc.c +++ b/gacopyz/proc.c @@ -1,5 +1,5 @@ /* This file is part of gacopyz. - Copyright (C) 2006 Sergey Poznyakoff + Copyright (C) 2006, 2007 Sergey Poznyakoff This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -21,7 +21,7 @@ static int cleanup_needed; static void -print_status(gacopyz_conn_t conn, pid_t pid, int status) +print_status(gacopyz_conn_t conn, pid_t pid, int status, int expect_term) { if (WIFEXITED(status)) { if (WEXITSTATUS(status) == 0) @@ -33,11 +33,16 @@ print_status(gacopyz_conn_t conn, pid_t pid, int status) "child %lu failed with status %d", (unsigned long) pid, WEXITSTATUS(status)); - } else if (WIFSIGNALED(status)) - gacopyz_log(conn, SMI_LOG_ERR, + } else if (WIFSIGNALED(status)) { + int prio; + if (expect_term && WTERMSIG(status) == SIGTERM) + prio = SMI_LOG_DEBUG; + else + prio = SMI_LOG_ERR; + gacopyz_log(conn, prio, "child %lu terminated on signal %d", (unsigned long) pid, WTERMSIG(status)); - else if (WIFSTOPPED(status)) + } else if (WIFSTOPPED(status)) gacopyz_log(conn, SMI_LOG_ERR, "child %lu stopped on signal %d", (unsigned long) pid, WSTOPSIG(status)); @@ -53,8 +58,8 @@ print_status(gacopyz_conn_t conn, pid_t pid, int status) (unsigned long) pid); } -void -gacopyz_cleanup_children(gacopyz_conn_t conn) +static void +cleanup_children(gacopyz_conn_t conn, int expect_term) { if (!cleanup_needed) return; @@ -63,17 +68,24 @@ gacopyz_cleanup_children(gacopyz_conn_t conn) pid_t pid = waitpid((pid_t)-1, &status, WNOHANG); if (pid <= 0) break; - print_status(conn, pid, status); + print_status(conn, pid, status, expect_term); } cleanup_needed = 0; } void +gacopyz_cleanup_children(gacopyz_conn_t conn) +{ + cleanup_children(conn, 0); +} + +void gacopyz_cleanup_conn(gacopyz_conn_t conn) { + gacopyz_log(conn, SMI_LOG_DEBUG, "terminating subprocesses"); signal(SIGTERM, SIG_IGN); kill(0, SIGTERM); - gacopyz_cleanup_children(conn); + cleanup_children(conn, 1); } static RETSIGTYPE |