* 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,36 +36,53 @@ main ()
if (ret) if (ret)
tst_brk (TBROK, NULL, NULL, "Reset SA_RESTART"); tst_brk (TBROK, NULL, NULL, "Reset SA_RESTART");
/* Set signal handler using signal(2) call... */ for (i = 0; i < 2; i++)
if (signal (SIGALRM, sig_handler) < 0) {
tst_brk (TBROK, NULL, NULL, "Call signal() to install signal handler"); if (pipe (fds) < 0)
/* ...and check if signal(2) sets SA_RESTART again. */ tst_brk (TBROK, NULL, NULL, "Create pipe");
while ((ret = sigaction (SIGALRM, NULL, &act)) == EINTR) /* Set signal handler using signal(2) call... */
; if (signal (SIGALRM, sig_handler) < 0)
if (ret) tst_brk (TBROK, NULL, NULL, "Call signal() to install signal handler");
tst_brk (TBROK, NULL, NULL, "Get signal action structure"); /* ...and check if signal(2) sets SA_RESTART again. */
tst_resm (act.sa_flags & SA_RESTART ? TPASS : TFAIL, while ((ret = sigaction (SIGALRM, NULL, &act)) == EINTR)
"signal() sets SA_RESTART"); ;
if (ret)
tst_brk (TBROK, NULL, NULL, "Get signal action structure");
tst_resm (act.sa_flags & SA_RESTART ? TPASS : TFAIL,
"signal() sets SA_RESTART");
/* Reset SA_RESTART flag again. */ const char *msg1, *msg2;
act.sa_handler = sig_handler; if (i == 1)
act.sa_flags &= ~SA_RESTART; {
while ((ret = sigaction (SIGALRM, &act, NULL)) == EINTR) siginterrupt (SIGALRM, 1);
; msg1 = "Reset SA_RESTART via siginterrupt";
if (ret) msg2 = "Set EINTR on interrupted read() call via siginterrupt";
tst_brk (TBROK, NULL, NULL, "Reset SA_RESTART"); }
else
{
/* Reset SA_RESTART flag again. */
act.sa_handler = sig_handler;
act.sa_flags &= ~SA_RESTART;
while ((ret = sigaction (SIGALRM, &act, NULL)) == EINTR)
;
msg1 = "Reset SA_RESTART via sigaction";
msg2 = "Set EINTR on interrupted read() call via sigaction";
}
if (ret)
tst_brk (TBROK, NULL, NULL, msg1);
/* Start timer to force a SIGALRM. */ /* Start timer to force a SIGALRM. */
alarm (1); alarm (1);
/* 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");