public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Dave Chinner <david@fromorbit.com>
To: xfs@oss.sgi.com
Subject: [PATCH 2/3] xfsqa: Fix signal usage in aio-dio test code
Date: Tue, 19 Jan 2010 20:03:11 +1100	[thread overview]
Message-ID: <1263891792-30952-3-git-send-email-david@fromorbit.com> (raw)
In-Reply-To: <1263891792-30952-1-git-send-email-david@fromorbit.com>

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 <david@fromorbit.com>
---
 src/aio-dio-regress/aio-dio-invalidate-failure.c |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/src/aio-dio-regress/aio-dio-invalidate-failure.c b/src/aio-dio-regress/aio-dio-invalidate-failure.c
index be01a3a..24f3e3c 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 <unistd.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include <signal.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <fcntl.h>
@@ -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);
-- 
1.6.5

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

  parent reply	other threads:[~2010-01-19  9:02 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-01-19  9:03 [PATCH 0/3] xfsqa: Fix various test-suite related failures Dave Chinner
2010-01-19  9:03 ` [PATCH 1/3] xfsqa: update 214 golden output Dave Chinner
2010-01-19  9:17   ` Christoph Hellwig
2010-01-19  9:03 ` Dave Chinner [this message]
2010-01-19  9:18   ` [PATCH 2/3] xfsqa: Fix signal usage in aio-dio test code Christoph Hellwig
2010-01-19  9:03 ` [PATCH 3/3] xfsqa: xfs_check can see stale cached blocks Dave Chinner
2010-01-19  9:19   ` Christoph Hellwig

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1263891792-30952-3-git-send-email-david@fromorbit.com \
    --to=david@fromorbit.com \
    --cc=xfs@oss.sgi.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox