diff options
-rw-r--r-- | .gitignore | 6 | ||||
-rw-r--r-- | Makefile | 50 | ||||
-rw-r--r-- | README | 5 | ||||
-rw-r--r-- | config.mk | 6 | ||||
-rw-r--r-- | pdeath.1 (renamed from doc/pdeath.1) | 17 | ||||
-rw-r--r-- | pdeath.c (renamed from src/pdeath.c) | 16 |
6 files changed, 42 insertions, 58 deletions
@@ -1,8 +1,6 @@ -\#*\# -.\#* *~ -/obj/ -/bin/ +*\#* *.out *.o *.su +/pdeath @@ -1,38 +1,32 @@ -PREFIX = /usr -BINDIR = $(PREFIX)/bin -DATADIR = $(PREFIX)/share -LICENSEDIR = $(DATADIR)/licences -MANDIR = $(DATADIR)/man -MAN1DIR = $(MANDIR)/man1 +.POSIX: -PKGNAME = pdeath -COMMAND = pdeath +CONFIGFILE = config.mk +include $(CONFIGFILE) -OPTIMISE = -O2 -WARN = -Wall -Wextra -pedantic +all: pdeath +.o: + $(CC) -o $@ $^ $(LDFLAGS) -all: cmd - -cmd: bin/pdeath - -bin/pdeath: src/pdeath.c - @mkdir -p bin - $(CC) -std=c99 $(OPTIMISE) $(WARN) -o $@ $^ +.c.o: + $(CC) -o $@ $< $(CPPFLAGS) $(CFLAGS) install: bin/pdeath - mkdir -p -- "$(DESTDIR)$(BINDIR)" - cp -- bin/pdeath "$(DESTDIR)$(BINDIR)/$(COMMAND)" - mkdir -p -- "$(DESTDIR)$(LICENSEDIR)/$(PKGNAME)" - cp -- LICENSE "$(DESTDIR)$(LICENSEDIR)/$(PKGNAME)/LICENSE" - mkdir -p -- "$(DESTDIR)$(MAN1DIR)" - cp doc/pdeath.1 -- "$(DESTDIR)$(MAN1DIR)/$(COMMAND).1" + mkdir -p -- "$(DESTDIR)$(PREFIX)/bin" + mkdir -p -- "$(DESTDIR)$(PREFIX)/share/licenses/pdeath" + mkdir -p -- "$(DESTDIR)$(MANPREFIX)/man1" + cp -- pdeath "$(DESTDIR)$(PREFIX)/bin/" + cp -- LICENSE "$(DESTDIR)$(PREFIX)/share/licenses/pdeath/" + cp -- pdeath.1 "$(DESTDIR)$(MANPREFIX)/man1/" uninstall: - -rm -- "$(DESTDIR)$(BINDIR)/$(COMMAND)" - -rm -- "$(DESTDIR)$(MAN1DIR)/$(COMMAND).1" - -rm -- "$(DESTDIR)$(LICENSEDIR)/$(PKGNAME)/LICENSE" - -rmdir -- "$(DESTDIR)$(LICENSEDIR)/$(PKGNAME)" + -rm -f -- "$(DESTDIR)$(PREFIX)/bin/pdeath" + -rm -f -- "$(DESTDIR)$(MANPREFIX)/man1/pdeath.1" + -rm -rf -- "$(DESTDIR)$(PREFIX)/share/licenses/pdeath" clean: - -rm -rf bin + -rm -f -- *.o pdeath + +SUFFIXES: .o .c.o + +.PHONY: all check install uninstall clean @@ -2,9 +2,7 @@ NAME pdeath - Run a command that is killed when its parent exits SYNOPSIS - pdeath signal[(+|-)off] command [argument]... - - pdeath -L + pdeath -L (signal[(+|-)off] command [argument] ...) DESCRIPTION pdeath runs the select command with the parent death signal set to @@ -16,4 +14,3 @@ OPTIONS LIMITATIONS pdeath cannot be used on binaries with set-user-ID or set-group-ID set. - diff --git a/config.mk b/config.mk new file mode 100644 index 0000000..9e148ca --- /dev/null +++ b/config.mk @@ -0,0 +1,6 @@ +PREFIX = /usr/local +MANPREFIX = $(PREFIX)/share/man + +CFLAGS = -std=c99 -Wall -Wextra -O2 +CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_XOPEN_SOURCE=700 +LDFLAGS = -s @@ -3,12 +3,10 @@ pdeath \- Run a command that is killed when its parent exits .SH SYNOPSIS .B pdeath -\fIsignal\fP[(\fB+\fP|\fB-\fP)\fIoff\fP] +(-L | +.RB \fIsignal\fP[( + | - )\fIoff\fP] .I command -.RI [ argument ]... -.P -.B pdeath -.B -L +.RI [ argument ]\ ...) .SH DESCRIPTION .B pdeath runs the select command with the parent death signal set to @@ -25,10 +23,5 @@ List all signals. .B pdeath cannot be used on binaries with set-user-ID or set-group-ID set. .SH AUTHORS -Principal author, Mattias Andrée. See the LICENSE file for the full -list of authors. -.SH LICENSE -ISC License. -.SH BUGS -Please report bugs to https://github.com/maandree/pdeath/issues or to -maandree@kth.se +Mattias Andrée +.RI < maandree@kth.se > @@ -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; } |