]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
bozo: small-notifier: don't ignore return from system()
authorGarrett Wollman <wollman@csail.mit.edu>
Mon, 16 Jul 2012 02:34:42 +0000 (22:34 -0400)
committerDerrick Brashear <shadow@dementix.org>
Mon, 16 Jul 2012 12:42:24 +0000 (05:42 -0700)
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 <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@dementix.org>
src/bozo/smail-notifier.c

index 1e7171198f5ddf096c270131ed5b8f0288bacc42..e9a0aa6e0c35894c6bede59429270e233a183d42 100644 (file)
@@ -14,6 +14,9 @@
 #include <roken.h>
 
 #include <afs/afsutil.h>
+#ifdef HAVE_SYS_WAIT_H
+#include <sys/wait.h>
+#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);
 }