From: Garrett Wollman Date: Mon, 16 Jul 2012 02:34:42 +0000 (-0400) Subject: bozo: small-notifier: don't ignore return from system() X-Git-Tag: upstream/1.8.0_pre1^2~2226 X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=d2ef4a6e1f685564ed51e8c1bc82642b406e936a;p=packages%2Fo%2Fopenafs.git 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 --- 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); }