/[MITgcm]/MITgcm/eesupp/src/sigreg.c
ViewVC logotype

Annotation of /MITgcm/eesupp/src/sigreg.c

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.4 - (hide annotations) (download)
Tue May 23 14:55:19 2006 UTC (18 years, 4 months ago) by edhill
Branch: MAIN
CVS Tags: checkpoint58h_post, checkpoint58j_post, checkpoint58f_post, checkpoint58i_post, checkpoint58g_post
Changes since 1.3: +2 -2 lines
File MIME type: text/plain
fix incorrect C syntax (all decls must appear before statements)

1 edhill 1.1 /*
2 edhill 1.4 * $Header: /u/gcmpack/MITgcm/eesupp/src/sigreg.c,v 1.3 2006/05/22 22:05:18 edhill Exp $
3 edhill 1.1 * $Name: $
4    
5     //BOP
6     // !ROUTINE: sigreg
7     // !INTERFACE:
8     sigreg()
9    
10     // !DESCRIPTION:
11     // Register a signal handler
12    
13     //EOP
14    
15     */
16    
17     /* Here, we get the definition of the FC_NAMEMANGLE() macro. */
18     #include "FC_NAMEMANGLE.h"
19    
20     /* #define FC_NAMEMANGLE(X) X ## _ */
21    
22 edhill 1.3 #ifdef HAVE_SIGREG
23 edhill 1.1 #include <stdlib.h>
24     #include <stdio.h>
25     #include <signal.h>
26     #include <errno.h>
27     #include <ucontext.h>
28 edhill 1.3 #endif
29 edhill 1.1
30     int * ip;
31    
32 edhill 1.3 #ifdef HAVE_SIGREG
33 edhill 1.1 static void killhandler(
34     unsigned int sn, siginfo_t si, struct ucontext *sc )
35     {
36     *ip = *ip + 1;
37     return;
38     }
39 edhill 1.3 #endif
40 edhill 1.1
41     /* int main( int argc, char ** argv ) */
42     void FC_NAMEMANGLE(sigreg) (int * aip)
43     {
44 edhill 1.3 #ifdef HAVE_SIGREG
45 edhill 1.2 struct sigaction s;
46 edhill 1.4 ip = aip;
47 edhill 1.1 s.sa_flags = SA_SIGINFO;
48     s.sa_sigaction = (void *)killhandler;
49     if(sigaction (SIGTERM,&s,(struct sigaction *)NULL)) {
50     printf("Sigaction returned error = %d\n", errno);
51     exit(0);
52     }
53 edhill 1.3 #endif
54 edhill 1.1 return;
55     }
56    
57    

  ViewVC Help
Powered by ViewVC 1.1.22