Back to home page

MITgcm

 
 

    


File indexing completed on 2018-03-02 18:36:13 UTC

view on githubraw file Latest commit add29e06 on 2018-01-31 20:35:05 UTC
b81731e160 Ed H*0001 /*
                0002 //BOP
                0003 // !ROUTINE: sigreg
                0004 // !INTERFACE:
                0005    sigreg()
                0006 
                0007 // !DESCRIPTION:
                0008 // Register a signal handler
                0009 
                0010 //EOP
                0011 
                0012 */
701c1edbb4 Cons*0013 #ifdef HAVE_SIGREG
b81731e160 Ed H*0014 /*  Here, we get the definition of the FC_NAMEMANGLE() macro. */
                0015 #include "FC_NAMEMANGLE.h"
                0016 
                0017 /* #define FC_NAMEMANGLE(X) X ## _ */
                0018 
343a48c623 Ed H*0019 #ifdef HAVE_SIGREG
b81731e160 Ed H*0020 #include <stdlib.h>
                0021 #include <stdio.h>
                0022 #include <signal.h>
                0023 #include <errno.h>
                0024 #include <ucontext.h>
                0025 
f84df7761e Oliv*0026 int * sigreg_ip;
b81731e160 Ed H*0027 
                0028 static void killhandler(
                0029     unsigned int sn, siginfo_t  si, struct ucontext *sc )
                0030 {
f84df7761e Oliv*0031     *sigreg_ip = *sigreg_ip + 1;
b81731e160 Ed H*0032     return;
                0033 }
343a48c623 Ed H*0034 #endif
b81731e160 Ed H*0035 
                0036 /* int main( int argc, char ** argv ) */
                0037 void FC_NAMEMANGLE(sigreg) (int * aip)
                0038 {
343a48c623 Ed H*0039 #ifdef HAVE_SIGREG
                0040     struct sigaction s;
f84df7761e Oliv*0041     sigreg_ip = aip;
b81731e160 Ed H*0042     s.sa_flags = SA_SIGINFO;
                0043     s.sa_sigaction = (void *)killhandler;
                0044     if(sigaction (SIGTERM,&s,(struct sigaction *)NULL)) {
                0045     printf("Sigaction returned error = %d\n", errno);
                0046     exit(0);
                0047     }
343a48c623 Ed H*0048 #endif
b81731e160 Ed H*0049     return;
                0050 }
701c1edbb4 Cons*0051 #endif
b81731e160 Ed H*0052