diff options
author | Mattias Andrée <maandree@kth.se> | 2017-10-17 20:11:30 +0200 |
---|---|---|
committer | Mattias Andrée <maandree@kth.se> | 2017-10-17 20:11:30 +0200 |
commit | a568a539bbbe387cef14185488a75e8d3825c68b (patch) | |
tree | 06ecb3bd0ec4e328ed6ad63a49de0f23c9b3f7fc /pdeath.c | |
parent | Makefile: fix uninstall rule: uninstall license (diff) | |
download | pdeath-a568a539bbbe387cef14185488a75e8d3825c68b.tar.gz pdeath-a568a539bbbe387cef14185488a75e8d3825c68b.tar.bz2 pdeath-a568a539bbbe387cef14185488a75e8d3825c68b.tar.xz |
Simplify
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to '')
-rw-r--r-- | pdeath.c (renamed from src/pdeath.c) | 16 |
1 files changed, 6 insertions, 10 deletions
@@ -1,5 +1,4 @@ /* See LICENSE file for copyright and license details. */ - #include <sys/prctl.h> #include <errno.h> #include <limits.h> @@ -10,8 +9,6 @@ #include <strings.h> #include <unistd.h> -#define FAILURE 127 - struct sig { int signo; const char *name; @@ -59,16 +56,15 @@ const char *argv0; static void usage(void) { - fprintf(stderr, "usage: %s (signal)[(+|-)off] command [arguments]...\n", argv0); - fprintf(stderr, "usage: %s -L\n", argv0); - exit(FAILURE); + fprintf(stderr, "usage: %s (-L | (signal)[(+|-)off] command [argument] ...)\n", argv0); + exit(127); } static void invalid_signal(void) { fprintf(stderr, "%s: invalid signal\n", argv0); - exit(FAILURE); + exit(127); } static void @@ -138,7 +134,7 @@ main(int argc, char *argv[]) print_signals(); if (fflush(stdout) || fclose(stdout)) { perror(argv0); - return FAILURE; + return 127; } return 0; } @@ -161,10 +157,10 @@ main(int argc, char *argv[]) if (prctl(PR_SET_PDEATHSIG, signo) == -1) { perror(argv0); - return FAILURE; + return 127; } execvp(*argv, argv); fprintf(stderr, "%s: %s: %s\n", argv0, strerror(errno), *argv); - return FAILURE; + return 127; } |