* winsup.api/checksignal.c (main): Add test for siginterrupt.

This commit is contained in:
Christopher Faylor 2006-03-23 15:52:16 +00:00
parent e3e63ca72b
commit 5b2daa7c97
2 changed files with 47 additions and 28 deletions

View File

@ -1,3 +1,7 @@
2006-03-23 Christopher Faylor <cgf@timesys.com>
* winsup.api/checksignal.c (main): Add test for siginterrupt.
2006-01-02 Christopher Faylor <cgf@timesys.com> 2006-01-02 Christopher Faylor <cgf@timesys.com>
* cygload/README: Delete. * cygload/README: Delete.

View File

@ -21,12 +21,10 @@ main ()
int fds[2]; int fds[2];
char buf[10]; char buf[10];
struct sigaction act; struct sigaction act;
int i;
Tst_count = 0; Tst_count = 0;
if (pipe (fds) < 0)
tst_brk (TBROK, NULL, NULL, "Create pipe");
/* Reset SA_RESTART flag. */ /* Reset SA_RESTART flag. */
while ((ret = sigaction (SIGALRM, NULL, &act)) == EINTR) while ((ret = sigaction (SIGALRM, NULL, &act)) == EINTR)
; ;
@ -38,6 +36,10 @@ main ()
if (ret) if (ret)
tst_brk (TBROK, NULL, NULL, "Reset SA_RESTART"); tst_brk (TBROK, NULL, NULL, "Reset SA_RESTART");
for (i = 0; i < 2; i++)
{
if (pipe (fds) < 0)
tst_brk (TBROK, NULL, NULL, "Create pipe");
/* Set signal handler using signal(2) call... */ /* Set signal handler using signal(2) call... */
if (signal (SIGALRM, sig_handler) < 0) if (signal (SIGALRM, sig_handler) < 0)
tst_brk (TBROK, NULL, NULL, "Call signal() to install signal handler"); tst_brk (TBROK, NULL, NULL, "Call signal() to install signal handler");
@ -49,13 +51,25 @@ main ()
tst_resm (act.sa_flags & SA_RESTART ? TPASS : TFAIL, tst_resm (act.sa_flags & SA_RESTART ? TPASS : TFAIL,
"signal() sets SA_RESTART"); "signal() sets SA_RESTART");
const char *msg1, *msg2;
if (i == 1)
{
siginterrupt (SIGALRM, 1);
msg1 = "Reset SA_RESTART via siginterrupt";
msg2 = "Set EINTR on interrupted read() call via siginterrupt";
}
else
{
/* Reset SA_RESTART flag again. */ /* Reset SA_RESTART flag again. */
act.sa_handler = sig_handler; act.sa_handler = sig_handler;
act.sa_flags &= ~SA_RESTART; act.sa_flags &= ~SA_RESTART;
while ((ret = sigaction (SIGALRM, &act, NULL)) == EINTR) while ((ret = sigaction (SIGALRM, &act, NULL)) == EINTR)
; ;
msg1 = "Reset SA_RESTART via sigaction";
msg2 = "Set EINTR on interrupted read() call via sigaction";
}
if (ret) if (ret)
tst_brk (TBROK, NULL, NULL, "Reset SA_RESTART"); tst_brk (TBROK, NULL, NULL, msg1);
/* Start timer to force a SIGALRM. */ /* Start timer to force a SIGALRM. */
alarm (1); alarm (1);
@ -63,11 +77,12 @@ main ()
/* Call read(2) to check if the EINTR errno is correctly preserved, /* Call read(2) to check if the EINTR errno is correctly preserved,
even if the signal handler routine changes errno. */ even if the signal handler routine changes errno. */
n = read(fds[0], buf, 10); n = read(fds[0], buf, 10);
tst_resm (n < 0 && errno == EINTR ? TPASS : TFAIL, tst_resm (n < 0 && errno == EINTR ? TPASS : TFAIL, msg2);
"Set EINTR on interrupted read() call"); close (fds[0]);
close (fds[1]);
}
/* Check if another errno is correctly returned (here EBADF). */ /* Check if another errno is correctly returned (here EBADF). */
close (fds[0]);
n = read(fds[0], buf, 10); n = read(fds[0], buf, 10);
tst_resm (n < 0 && errno == EBADF ? TPASS : TFAIL, tst_resm (n < 0 && errno == EBADF ? TPASS : TFAIL,
"Set EBADF on closed file descriptor"); "Set EBADF on closed file descriptor");