exit with code of subprocess
This commit is contained in:
parent
06dd2f8566
commit
eebb40fc49
13
st.c
13
st.c
|
@ -664,6 +664,17 @@ die(const char *errstr, ...)
|
||||||
exit(1);
|
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
|
void
|
||||||
execsh(char *cmd, char **args)
|
execsh(char *cmd, char **args)
|
||||||
{
|
{
|
||||||
|
@ -735,7 +746,7 @@ sigchld(int a)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (WIFEXITED(stat) && WEXITSTATUS(stat))
|
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))
|
else if (WIFSIGNALED(stat))
|
||||||
die("child terminated due to signal %d\n", WTERMSIG(stat));
|
die("child terminated due to signal %d\n", WTERMSIG(stat));
|
||||||
_exit(0);
|
_exit(0);
|
||||||
|
|
Loading…
Reference in New Issue