From 484590872abfa604bb3e9a40699d85b14c9ad5bc Mon Sep 17 00:00:00 2001 From: Dave Chinner Date: Wed, 20 Jan 2010 10:28:24 +1100 Subject: [PATCH] xfsqa: Fix signal usage in aio-dio test code Using signal() to set up signal handlers doesn't always do what you want. A recent upgrade made test 208 fail because wait() was not getting interrupted by a SIGALRM. Tracing showed that signal() was being converted to a sigaction(SA_RESTART) handler, which allows syscalls that return ERESTARTSYS to immediately restart without returning EINTR to the calling process. The kernel code returns ERESTARTSYS to signal interruptions while in wait(). Replace the use of signal with sigaction() to ensure that the SA_RESTART flag is not set and the EINTR is delivered to the process sitting in wait(). This makes test 208 terminate at 200s again. Signed-off-by: Dave Chinner Reviewed-by: Christoph Hellwig --- src/aio-dio-regress/aio-dio-invalidate-failure.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/aio-dio-regress/aio-dio-invalidate-failure.c b/src/aio-dio-regress/aio-dio-invalidate-failure.c index be01a3af..24f3e3c6 100644 --- a/src/aio-dio-regress/aio-dio-invalidate-failure.c +++ b/src/aio-dio-regress/aio-dio-invalidate-failure.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -117,6 +118,7 @@ int main(int argc, char **argv) int fd; int fd2; int status; + struct sigaction sa; if (argc != 2) fail("only arg should be file name"); @@ -150,7 +152,12 @@ int main(int argc, char **argv) exit(0); } - signal(SIGALRM, alarm_handler); + memset(&sa, 0, sizeof(sa)); + sa.sa_handler = alarm_handler; + sigemptyset(&sa.sa_mask); + if (sigaction(SIGALRM, &sa, NULL) == -1) + fail("sigaction: %d\n", errno); + alarm(SECONDS); pid = wait(&status); -- 2.47.3