exit with code of subprocess

This commit is contained in:
randomuser 2023-02-04 15:27:01 -06:00
parent 06dd2f8566
commit eebb40fc49
2 changed files with 13 additions and 1 deletions

13
st.c
View File

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

1
st.h
View File

@ -78,6 +78,7 @@ typedef union {
} Arg;
void die(const char *, ...);
void die_error(int err, const char *, ...);
void redraw(void);
void draw(void);