From: <ro...@us...> - 2003-04-29 15:01:32
|
Update of /cvsroot/ltp/ltp/testcases/kernel/syscalls/pipe In directory sc8-pr-cvs1:/tmp/cvs-serv16448 Modified Files: pipe05.c Log Message: Applied patch from Jacky Malcles to handle architectures that send a SIGSEGV before the EFAULT can be caught. Index: pipe05.c =================================================================== RCS file: /cvsroot/ltp/ltp/testcases/kernel/syscalls/pipe/pipe05.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- pipe05.c 27 Mar 2003 16:47:30 -0000 1.3 +++ pipe05.c 29 Apr 2003 15:01:27 -0000 1.4 @@ -45,6 +45,7 @@ */ #include <fcntl.h> #include <errno.h> +#include <setjmp.h> #include "test.h" #include "usctest.h" @@ -57,11 +58,15 @@ intptr_t pipes; void setup(void); void cleanup(void); +jmp_buf sig11_recover; +void sig11_handler(int sig); + int main(int ac, char **av) { int lc; /* loop counter */ char *msg; /* message returned from parse_opts */ + struct sigaction sa, osa; /* parse standard options */ if ((msg = parse_opts(ac, av, (option_t *)NULL, NULL)) != (char *)NULL){ @@ -77,8 +82,21 @@ /* reset Tst_count in case we are looping */ Tst_count = 0; + /* special sig11 case */ + sa.sa_handler = &sig11_handler; + sigemptyset(&sa.sa_mask); + sa.sa_flags = 0; + sigaction(SIGSEGV, NULL, &osa); + sigaction(SIGSEGV, &sa, NULL); + + if (setjmp(sig11_recover)) { + TEST_RETURN = -1; + TEST_ERRNO = EFAULT; + } else { TEST(pipe((int *)pipes)); + } + sigaction(SIGSEGV, &osa, NULL); if (TEST_RETURN != -1) { tst_resm(TFAIL, "call succeeded unexpectedly"); @@ -113,6 +131,15 @@ /* Pause if that option was specified */ TEST_PAUSE; } +/****************************************************************** + * sig11_handler() - our segfault recover hack + ******************************************************************/ +void +sig11_handler(int sig) +{ + longjmp(sig11_recover, 1); +} + /* * cleanup() - performs all ONE TIME cleanup for this test at @@ -130,3 +157,4 @@ /* exit with return code appropriate for results */ tst_exit(); } + |