T_exitval is defined as 'static int' in lib/tst_res.c, so it won't be
accessed directly from other source files.

Consider below scenario:
If a testcase need to fork a child process to do test work, indeed child
process is ok to call tst_resm() or tst_brkm(), in the end, child process
should also call tst_exit() to report the test result to parent process.

Then we should avoid the potential risk introduced by the kernel COW mechanism
when forking, so every child process should first call tst_reset_exitval() at
the beginning of the test.

Signed-off-by: Xiaoguang Wang <wangxg.f...@cn.fujitsu.com>
---
 include/test.h | 1 +
 lib/tst_res.c  | 4 ++++
 2 files changed, 5 insertions(+)

diff --git a/include/test.h b/include/test.h
index a4a23e3..3d8bb7c 100644
--- a/include/test.h
+++ b/include/test.h
@@ -118,6 +118,7 @@ extern int Forker_npids;
 
 /* lib/tst_res.c */
 const char *strttype(int ttype);
+void tst_reset_exitval(void);
 void tst_res(int ttype, const char *fname, const char *arg_fmt, ...)
        __attribute__ ((format (printf, 3, 4)));
 void tst_resm(int ttype, const char *arg_fmt, ...)
diff --git a/lib/tst_res.c b/lib/tst_res.c
index 31186e0..079fc42 100644
--- a/lib/tst_res.c
+++ b/lib/tst_res.c
@@ -224,6 +224,10 @@ const char *strttype(int ttype)
 /* Include table of signals and tst_strsig() function*/
 #include "signame.h"
 
+void tst_reset_exitval(void)
+{
+       T_exitval = 0;
+}
 /*
  * tst_res() - Main result reporting function.  Handle test information
  *             appropriately depending on output display mode.  Call
-- 
1.8.2.1


------------------------------------------------------------------------------
Open source business process management suite built on Java and Eclipse
Turn processes into business applications with Bonita BPM Community Edition
Quickly connect people, data, and systems into organized workflows
Winner of BOSSIE, CODIE, OW2 and Gartner awards
http://p.sf.net/sfu/Bonitasoft
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

Reply via email to