mirror of
https://github.com/linux-apfs/apfstests.git
synced 2026-05-01 15:01:44 -07:00
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 <david@fromorbit.com> Reviewed-by: Christoph Hellwig <hch@lst.de>
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user