diff options
author | Daniel Vetter <daniel.vetter@ffwll.ch> | 2013-08-12 10:39:33 +0200 |
---|---|---|
committer | Daniel Vetter <daniel.vetter@ffwll.ch> | 2013-08-12 11:10:26 +0200 |
commit | a4038d3853b98707a803f5d1fb5c9ebe32f0b84b (patch) | |
tree | abbe8a1b65836babb48782f10b495087bbd781e5 /lib | |
parent | 740065f0f9cd8f5add5520e6b3db6b02befee0a9 (diff) |
lib/drmtest: make signal process cleanup more robust
If we skip a test and and fail somewhere the parent might die before the
child. So add some cleanup to handle this case. Also make sure that the
parent indeed waits for the child to die.
This is required to make the latest version of the piglit runner happy,
it tends to wait for all zombies to disappear.
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/drmtest.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/lib/drmtest.c b/lib/drmtest.c index 767c8dc83..77e8002e6 100644 --- a/lib/drmtest.c +++ b/lib/drmtest.c @@ -625,11 +625,18 @@ static void sig_handler(int i) sig_stat++; } +static void signal_helper_exit_handler(int sig) +{ + drmtest_stop_signal_helper(); +} + void drmtest_fork_signal_helper(void) { pid_t pid; sighandler_t oldsig; + drmtest_install_exit_handler(signal_helper_exit_handler); + signal(SIGUSR1, sig_handler); oldsig = signal(SIGQUIT, SIG_DFL); pid = fork(); @@ -644,8 +651,12 @@ void drmtest_fork_signal_helper(void) void drmtest_stop_signal_helper(void) { - if (signal_helper != -1) + int exitcode; + + if (signal_helper != -1) { kill(signal_helper, SIGQUIT); + wait(&exitcode); + } if (sig_stat) fprintf(stdout, "signal handler called %llu times\n", sig_stat); |