Standardize License information
[openafs.git] / src / bozo / test / testproc.c
1 /*
2  * Copyright 2000, International Business Machines Corporation and others.
3  * All Rights Reserved.
4  * 
5  * This software has been released under the terms of the IBM Public
6  * License.  For details, see the LICENSE file in the top-level source
7  * directory or online at http://www.openafs.org/dl/license10.html
8  */
9
10 #include <sys/types.h>
11 #include <signal.h>
12
13 static int ignore=0;
14 static int sleepTime = 10;
15
16 sigproc() {
17     printf("testproc received signal\n");
18     if (ignore) return 0;
19     exit(0);
20 }
21
22 main(argc, argv)
23 int argc;
24 char **argv; {
25     register int i;
26
27 #ifdef  AFS_AIX31_ENV
28     /*
29      * The following signal action for AIX is necessary so that in case of a 
30      * crash (i.e. core is generated) we can include the user's data section 
31      * in the core dump. Unfortunately, by default, only a partial core is
32      * generated which, in many cases, isn't too useful.
33      */
34     struct sigaction nsa;
35     
36     sigemptyset(&nsa.sa_mask);
37     nsa.sa_handler = SIG_DFL;
38     nsa.sa_flags = SA_FULLDUMP;
39     sigaction(SIGSEGV, &nsa, NULL);
40 #endif
41     signal(SIGTERM, sigproc);
42     signal(SIGQUIT, sigproc);
43     for(i=1;i<argc;i++) {
44         if (strcmp(argv[i], "-ignore")==0) {
45             ignore = 1;
46         }
47         else if (strcmp(argv[i], "-sleep")==0) {
48             sleepTime = atoi(argv[i+1]);
49             i++;
50         }
51         else {
52             printf("unrecognized option '%s', try one of\n", argv[i]);
53             printf("-ignore         ignore SIGTERM signal\n");
54             printf("-sleep <n>      sleep N seconds before exiting\n");
55             exit(1);
56         }
57     }
58     sleep(sleepTime);
59     exit(0);
60 }