From: Xiaoguang W. <wan...@cn...> - 2014-05-16 04:58:22
|
Hi, I forgot to send this patch first, please review this patch first, thanks. Regards, Xiaoguang Wang On 05/16/2014 12:52 PM, Xiaoguang Wang wrote: > Signed-off-by: Xiaoguang Wang <wan...@cn...> > --- > include/safe_macros.h | 5 +++++ > lib/safe_macros.c | 16 ++++++++++++++++ > 2 files changed, 21 insertions(+) > > diff --git a/include/safe_macros.h b/include/safe_macros.h > index 9e3ba98..c79dadf 100644 > --- a/include/safe_macros.h > +++ b/include/safe_macros.h > @@ -231,5 +231,10 @@ pid_t safe_waitpid(const char *file, const int lineno, void (cleanup_fn)(void), > #define SAFE_WAITPID(cleanup_fn, pid, status, opts) \ > safe_waitpid(__FILE__, __LINE__, (cleanup_fn), (pid), (status), (opts)) > > +int safe_kill(const char *file, const int lineno, void (cleanup_fn)(void), > + pid_t pid, int sig); > +#define SAFE_KILL(cleanup_fn, pid, sig) \ > + safe_kill(__FILE__, __LINE__, (cleanup_fn), (pid), (sig)) > + > #endif /* __SAFE_MACROS_H__ */ > #endif /* __TEST_H__ */ > diff --git a/lib/safe_macros.c b/lib/safe_macros.c > index 48a837c..81c66b5 100644 > --- a/lib/safe_macros.c > +++ b/lib/safe_macros.c > @@ -659,3 +659,19 @@ pid_t safe_waitpid(const char *file, const int lineno, void (cleanup_fn)(void), > > return rval; > } > + > +int safe_kill(const char *file, const int lineno, void (cleanup_fn)(void), > + pid_t pid, int sig) > +{ > + int rval; > + > + rval = kill(pid, sig); > + > + if (rval == -1) { > + tst_brkm(TBROK | TERRNO, cleanup_fn, > + "%s:%d: kill(%d,%s) failed", > + file, lineno, pid, tst_strsig(sig)); > + } > + > + return rval; > +} |