test: plug small memory leak in unix test runner

Join the watchdog thread unconditionally on exit.  Fixes the following
harmless but noisy memory leak:

    576 bytes in 1 blocks are possibly lost in loss record 1 of 2
       at 0x4C2A9C7: calloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
       by 0x40121B4: _dl_allocate_tls (in /usr/lib64/ld-2.21.so)
       by 0x5AEA045: pthread_create@@GLIBC_2.2.5 (in /usr/lib64/libpthread-2.21.so)
       by 0x450D3E: process_wait (runner-unix.c:212)
       by 0x4067F1: run_test (runner.c:284)
       by 0x405EC3: maybe_run_test (run-tests.c:180)
       by 0x4058AD: main (run-tests.c:57)

PR-URL: https://github.com/libuv/libuv/pull/479
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
This commit is contained in:
Ben Noordhuis 2015-08-17 01:36:53 +02:00
parent e19764f75a
commit 54eecf32a9

View File

@ -267,15 +267,11 @@ int process_wait(process_info_t* vec, int n, int timeout) {
kill(p->pid, SIGTERM);
}
retval = -2;
/* Wait for thread to finish. */
r = pthread_join(tid, NULL);
if (r) {
perror("pthread_join");
retval = -1;
}
}
if (pthread_join(tid, NULL))
abort();
terminate:
close(args.pipe[0]);
close(args.pipe[1]);