From eebb40fc4968524cc8ef4c3d5323241fdb257446 Mon Sep 17 00:00:00 2001 From: randomuser Date: Sat, 4 Feb 2023 15:27:01 -0600 Subject: [PATCH] exit with code of subprocess --- st.c | 13 ++++++++++++- st.h | 1 + 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/st.c b/st.c index ebfd5e0..bebfa9d 100644 --- a/st.c +++ b/st.c @@ -664,6 +664,17 @@ die(const char *errstr, ...) exit(1); } +void +die_err(int err, const char *errstr, ...) +{ + va_list ap; + + va_start(ap, errstr); + vfprintf(stderr, errstr, ap); + va_end(ap); + exit(err); +} + void execsh(char *cmd, char **args) { @@ -735,7 +746,7 @@ sigchld(int a) } if (WIFEXITED(stat) && WEXITSTATUS(stat)) - die("child exited with status %d\n", WEXITSTATUS(stat)); + die_err(WEXITSTATUS(stat), "child exited with status %d\n", WEXITSTATUS(stat)); else if (WIFSIGNALED(stat)) die("child terminated due to signal %d\n", WTERMSIG(stat)); _exit(0); diff --git a/st.h b/st.h index ee3bee2..46d1f5d 100644 --- a/st.h +++ b/st.h @@ -78,6 +78,7 @@ typedef union { } Arg; void die(const char *, ...); +void die_error(int err, const char *, ...); void redraw(void); void draw(void);