From: Imre Deak Date: Wed, 22 May 2013 14:40:45 +0000 (+0300) Subject: lib: fix exit handler when multiple handlers are registered X-Git-Tag: intel-gpu-tools-1.4~387 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4dec89aef746a60a98a1b93823e79b51a5a8a3c6;p=platform%2Fupstream%2Fintel-gpu-tools.git lib: fix exit handler when multiple handlers are registered Signed-off-by: Imre Deak Signed-off-by: Daniel Vetter --- diff --git a/lib/drmtest.c b/lib/drmtest.c index 981ab4b..9fc03a0 100644 --- a/lib/drmtest.c +++ b/lib/drmtest.c @@ -1065,7 +1065,7 @@ static void call_exit_handlers(int sig) return; } - for (i = 0; i < exit_handler_count; i++) + for (i = exit_handler_count - 1; i >= 0; i--) exit_handler_fn[i](sig); } @@ -1111,6 +1111,9 @@ static int drmtest_install_exit_handler(drmtest_exit_handler_t fn) exit_handler_fn[exit_handler_count] = fn; exit_handler_count++; + if (exit_handler_count > 1) + return 0; + for (i = 0; i < ARRAY_SIZE(handled_signals); i++) { if (install_sig_handler(handled_signals[i], drmtest_sig_handler))