From d8872c43b48eae5501998a4e5a84337017d8fbe6 Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Sat, 31 May 2014 12:33:24 -0500 Subject: Introduce xfork() and make commands use it, and make some WEXITSTATUS() use WIFEXITED() and WTERMSIG()+127. --- lib/lib.h | 1 + lib/xwrap.c | 9 +++++++++ 2 files changed, 10 insertions(+) (limited to 'lib') diff --git a/lib/lib.h b/lib/lib.h index 09af2837..3ca631b6 100644 --- a/lib/lib.h +++ b/lib/lib.h @@ -91,6 +91,7 @@ void xprintf(char *format, ...); void xputs(char *s); void xputc(char c); void xflush(void); +pid_t xfork(void); void xexec_optargs(int skip); void xexec(char **argv); void xaccess(char *path, int flags); diff --git a/lib/xwrap.c b/lib/xwrap.c index 69682f65..3e146fb7 100644 --- a/lib/xwrap.c +++ b/lib/xwrap.c @@ -113,6 +113,15 @@ void xflush(void) if (fflush(stdout) || ferror(stdout)) perror_exit("write");; } +pid_t xfork(void) +{ + pid_t pid = fork(); + + if (pid < 0) perror_exit("fork"); + + return pid; +} + // Call xexec with a chunk of optargs, starting at skip. (You can't just // call xexec() directly because toy_init() frees optargs.) void xexec_optargs(int skip) -- cgit v1.2.3