aboutsummaryrefslogtreecommitdiffstats
path: root/pdeath.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2017-10-17 20:11:30 +0200
committerMattias Andrée <maandree@kth.se>2017-10-17 20:11:30 +0200
commita568a539bbbe387cef14185488a75e8d3825c68b (patch)
tree06ecb3bd0ec4e328ed6ad63a49de0f23c9b3f7fc /pdeath.c
parentMakefile: fix uninstall rule: uninstall license (diff)
downloadpdeath-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
diff --git a/src/pdeath.c b/pdeath.c
index 2d564a8..2cdbee2 100644
--- a/src/pdeath.c
+++ b/pdeath.c
@@ -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;
}