diff options
-rw-r--r-- | lib/lib.h | 1 | ||||
-rw-r--r-- | lib/xwrap.c | 6 | ||||
-rw-r--r-- | toys/pending/syslogd.c | 2 | ||||
-rw-r--r-- | toys/pending/tar.c | 2 |
4 files changed, 9 insertions, 2 deletions
@@ -119,6 +119,7 @@ void xaccess(char *path, int flags); void xunlink(char *path); int xcreate(char *path, int flags, int mode); int xopen(char *path, int flags); +void xpipe(int pp); void xclose(int fd); int xdup(int fd); FILE *xfdopen(int fd, char *mode); diff --git a/lib/xwrap.c b/lib/xwrap.c index 65e3018d..76b0ff37 100644 --- a/lib/xwrap.c +++ b/lib/xwrap.c @@ -33,6 +33,7 @@ void xexit(void) if (toys.rebound) longjmp(*toys.rebound, 1); if (fflush(NULL) || ferror(stdout)) if (!toys.exitval) perror_msg("write"); + exit(toys.exitval); } @@ -309,6 +310,11 @@ int xopen(char *path, int flags) return xcreate(path, flags, 0); } +void xpipe(int pp) +{ + if (pipe(pp)) perror_exit("xpipe"); +} + void xclose(int fd) { if (close(fd)) perror_exit("xclose"); diff --git a/toys/pending/syslogd.c b/toys/pending/syslogd.c index 450bd72f..73542cac 100644 --- a/toys/pending/syslogd.c +++ b/toys/pending/syslogd.c @@ -460,7 +460,7 @@ init_jumpin: } // Setup signals - if (pipe(TT.sigfd) < 0) error_exit("pipe failed\n"); + xpipe(TT.sigfd); fcntl(TT.sigfd[1] , F_SETFD, FD_CLOEXEC); fcntl(TT.sigfd[0] , F_SETFD, FD_CLOEXEC); diff --git a/toys/pending/tar.c b/toys/pending/tar.c index c8b6dff8..6140ea5d 100644 --- a/toys/pending/tar.c +++ b/toys/pending/tar.c @@ -287,7 +287,7 @@ static void compress_stream(struct archive_handler *tar_hdl) int pipefd[2]; pid_t cpid; - if (pipe(pipefd) == -1) error_exit("pipe"); + xpipe(pipefd); signal(SIGPIPE, SIG_IGN); cpid = fork(); |