From d2ef4a6e1f685564ed51e8c1bc82642b406e936a Mon Sep 17 00:00:00 2001 From: Garrett Wollman Date: Sun, 15 Jul 2012 22:34:42 -0400 Subject: [PATCH] bozo: small-notifier: don't ignore return from system() Nobody can possibly be using this program, but even so, don't ignore return values. Unfortunately, the return value of system() is a bit complicated to interpret. Change-Id: I6edbbb7c010b4e534de9033b91849e2d54bf4b25 Reviewed-on: http://gerrit.openafs.org/7778 Tested-by: BuildBot Reviewed-by: Derrick Brashear --- src/bozo/smail-notifier.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/bozo/smail-notifier.c b/src/bozo/smail-notifier.c index 1e7171198..e9a0aa6e0 100644 --- a/src/bozo/smail-notifier.c +++ b/src/bozo/smail-notifier.c @@ -14,6 +14,9 @@ #include #include +#ifdef HAVE_SYS_WAIT_H +#include +#endif /* * XXX CHANGE the following depedent stuff XXX @@ -211,6 +214,18 @@ main(int argc, char **argv) */ sprintf(bufp1, "%s %s -s TESTING < %s", SENDMAIL, RECIPIENT, buf); code = system(bufp1); + if (code == -1) + perror("system"); + else if (code == 127) + fprintf(stderr, "system: unable to execute shell\n"); +#ifdef WTERMSIG + else if (WIFSIGNALED(code)) + fprintf(stderr, "%s terminated with signal %d\n", SENDMAIL, + WTERMSIG(code)); + else if (WEXITSTATUS(code) != 0) + fprintf(stderr, "%s exited with status %d\n", SENDMAIL, + WEXITSTATUS(code)); +#endif /* WTERMSIG */ unlink(buf); exit(0); } -- 2.39.5