From 85f54d8e836ac80264111df7d87db6c15eaca558 Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Mon, 8 Feb 2016 15:24:33 -0600 Subject: Add xpipe() to lib. --- lib/lib.h | 1 + lib/xwrap.c | 6 ++++++ 2 files changed, 7 insertions(+) (limited to 'lib') diff --git a/lib/lib.h b/lib/lib.h index 5733103b..c111aeb0 100644 --- a/lib/lib.h +++ b/lib/lib.h @@ -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"); -- cgit v1.2.3