From: <ch...@su...> - 2014-07-02 12:53:11
|
Hi! > diff --git a/lib/tst_res.c b/lib/tst_res.c > index 079fc42..24fb4d9 100644 > --- a/lib/tst_res.c > +++ b/lib/tst_res.c > @@ -101,6 +101,9 @@ > #include <stdarg.h> > #include <string.h> > #include <unistd.h> > +#include <sys/types.h> > +#include <sys/wait.h> > + > #include "test.h" > #include "usctest.h" > #include "ltp_priv.h" > @@ -228,6 +231,40 @@ void tst_reset_exitval(void) > { > T_exitval = 0; > } > + > +int tst_record_childstatus(int status, int *sig) > +{ > + int ret = 0, ttype_result, s = 0; > + > + if (WIFEXITED(status)) { > + ret = WEXITSTATUS(status); > + ttype_result = TTYPE_RESULT(ret); > + T_exitval |= ttype_result; > + s = 0; > + ret = CHILD_EXIT_NORMALLY; > + } else if (WIFSIGNALED(status)) { > + s = WTERMSIG(status); > + tst_resm(TINFO, "child process is killed by signal: %s(%d)", > + tst_strsig(s), s); > + ret = CHILD_EXIT_SIGNALED; I would not bother with the return value and just do tst_brkm() with TBROK in the rest of the cases. Because child killed by a signal is a very special case and testcases that needs to assert it can do the wait() and WIFSIGNALED() themselves. -- Cyril Hrubis ch...@su... |