* winsup.api/resethand.c: New file.
This commit is contained in:
		| @@ -1,3 +1,7 @@ | ||||
| 2006-01-01  Christopher Faylor  <cgf@timesys.com> | ||||
|  | ||||
| 	* winsup.api/resethand.c: New file. | ||||
|  | ||||
| 2005-12-11  Christopher Faylor  <cgf@timesys.com> | ||||
|  | ||||
| 	* winsup.api/ltp/dup03.c (cleanup): Fix longstanding off-by-one error | ||||
|   | ||||
							
								
								
									
										35
									
								
								winsup/testsuite/winsup.api/resethand.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										35
									
								
								winsup/testsuite/winsup.api/resethand.c
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,35 @@ | ||||
| #include <stdio.h> | ||||
| #include <signal.h> | ||||
| #include <sys/wait.h> | ||||
| #include <unistd.h> | ||||
| #include <stdlib.h> | ||||
|  | ||||
| int doit = 0; | ||||
| void | ||||
| ouch (int sig) | ||||
| { | ||||
|   fprintf (stderr, "ouch %d\n", sig); | ||||
|   if (doit++ == 0) | ||||
|     kill (getpid (), SIGTERM); | ||||
| } | ||||
|  | ||||
| int | ||||
| main (int argc, char **argv) | ||||
| { | ||||
|   static struct sigaction act; | ||||
|   if (argc == 1) | ||||
|     act.sa_flags = SA_RESETHAND; | ||||
|   act.sa_handler = ouch; | ||||
|   sigaction (SIGTERM, &act, NULL); | ||||
|   int pid = fork (); | ||||
|   int status; | ||||
|   if (pid > 0) | ||||
|     waitpid (pid, &status, 0); | ||||
|   else | ||||
|     { | ||||
|       kill (getpid (), SIGTERM); | ||||
|       exit (0x27); | ||||
|     } | ||||
|   fprintf (stderr, "pid %d exited with status %p\n", pid, status); | ||||
|   exit (argc == 1 ? !(status == SIGTERM) : !(status == 0x2700)); | ||||
| } | ||||
		Reference in New Issue
	
	Block a user