X-Git-Url: http://git.ozlabs.org/?p=ccan;a=blobdiff_plain;f=ccan%2Ftap%2Ftap.c;fp=ccan%2Ftap%2Ftap.c;h=6e268324446b7d1e33a7953005306b971ba1cf4b;hp=4bbd977bbfdd6f3312295afb67a3d9e5d7832206;hb=30d3e635ecef7961777a1aa98b1bde23712d6547;hpb=6502a8728975624437e172ea6b034b24295ceda5 diff --git a/ccan/tap/tap.c b/ccan/tap/tap.c index 4bbd977b..6e268324 100644 --- a/ccan/tap/tap.c +++ b/ccan/tap/tap.c @@ -28,6 +28,7 @@ #include #include #include +#include #include "tap.h" @@ -41,6 +42,7 @@ static char *todo_msg = NULL; static char *todo_msg_fixed = "libtap malloc issue"; static int todo = 0; static int test_died = 0; +static int test_pid; /* Encapsulate the pthread code in a conditional. In the absence of libpthread the code does nothing */ @@ -185,6 +187,9 @@ _gen_result(int ok, const char *func, char *file, unsigned int line, static void _cleanup(void) { + /* If we forked, don't do cleanup in child! */ + if (getpid() != test_pid) + return; LOCK; @@ -245,6 +250,7 @@ _tap_init(void) static int run_once = 0; if(!run_once) { + test_pid = getpid(); atexit(_cleanup); /* stdout needs to be unbuffered so that the output appears