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);