Loading...
Searching...
No Matches
cntrlc.h File Reference
`#include <setjmp.h>`
`#include "kernel/mod2.h"`
`#include "kernel/structs.h"`

Go to the source code of this file.

## Typedefs

typedef void(* | si_hdl_typ) (int)

## Functions

void | init_signals (void)
| init signal handlers and error handling for libraries: NTL, factory
void | si_set_signals ()
void | si_reset_signals ()
void | sig_term_hdl_child (int)
void | sig_term_hdl (int)
si_hdl_typ | si_set_signal (int sig, si_hdl_typ signal_handler)
| meta function for binding a signal to an handler

## Variables

EXTERN_VAR jmp_buf | si_start_jmpbuf
EXTERN_VAR short | si_restart
EXTERN_VAR int | siRandomStart
EXTERN_VAR BOOLEAN | singular_in_batchmode
EXTERN_VAR volatile BOOLEAN | do_shutdown
EXTERN_VAR volatile int | defer_shutdown

## Typedef Documentation

## si_hdl_typ

typedef void(* si_hdl_typ) (int)

Definition at line 30 of file cntrlc.h.

## Function Documentation

## init_signals()

void init_signals | ( | void |  | ) |

init signal handlers and error handling for libraries: NTL, factory

Definition at line 530 of file cntrlc.cc.

{
// signal handler -------------------------------------------------------
#ifdef SIGSEGV
si_set_signal(SIGSEGV,(si_hdl_typ)sigsegv_handler);
#endif
#ifdef SIGBUS
si_set_signal(SIGBUS, (si_hdl_typ)sigsegv_handler);
#endif
#ifdef SIGFPE
si_set_signal(SIGFPE, (si_hdl_typ)sigsegv_handler);
#endif
#ifdef SIGILL
si_set_signal(SIGILL, (si_hdl_typ)sigsegv_handler);
#endif
#ifdef SIGIOT
si_set_signal(SIGIOT, (si_hdl_typ)sigsegv_handler);
#endif
si_set_signal(SIGINT ,(si_hdl_typ)sigint_handler);
si_set_signal(SIGCHLD, (si_hdl_typ)sig_chld_hdl);
si_set_signal(SIGPIPE, (si_hdl_typ)sig_pipe_hdl);
si_set_signal(SIGTERM, (si_hdl_typ)sig_term_hdl);
}
sig_pipe_hdl
void sig_pipe_hdl(int)
Definition cntrlc.cc:64
si_set_signal
si_hdl_typ si_set_signal(int sig, si_hdl_typ signal_handler)
meta function for binding a signal to an handler
Definition cntrlc.cc:121
sig_term_hdl
void sig_term_hdl(int)
Definition cntrlc.cc:77
sigint_handler
void sigint_handler(int)
Definition cntrlc.cc:269
sigsegv_handler
void sigsegv_handler(int sig)
Definition cntrlc.cc:237
si_hdl_typ
void(* si_hdl_typ)(int)
Definition cntrlc.h:30
sig_chld_hdl
void sig_chld_hdl(int)
additional default signal handler
Definition ssiLink.cc:3265

## si_reset_signals()

void si_reset_signals | ( |  | ) |

Definition at line 568 of file cntrlc.cc.

{
// signal handler -------------------------------------------------------
//si_set_signal(SIGINT ,si_sigint_handler);
si_set_signal(SIGCHLD, old_sig_chld_hdl);
//si_set_signal(SIGPIPE, si_sig_pipe_hdl);
si_set_signal(SIGTERM, si_sig_term_hdl);
}
si_sig_term_hdl
VAR si_hdl_typ si_sig_term_hdl
Definition cntrlc.cc:558
old_sig_chld_hdl
VAR si_hdl_typ old_sig_chld_hdl
Definition cntrlc.cc:556

## si_set_signal()

si_hdl_typ si_set_signal | ( | int | sig,
|  | si_hdl_typ | signal_handler )

meta function for binding a signal to an handler

Parameters

  [in] | sig | Signal number
  [in] | signal_handler | Pointer to signal handler

Returns
  value of signal()

Definition at line 121 of file cntrlc.cc.

{
#if 0
si_hdl_typ retval=signal (sig, (si_hdl_typ)signal_handler);
if (retval == SIG_ERR)
{
fprintf(stderr, "Unable to init signal %d ... exiting...\n", sig);
}
si_siginterrupt(sig, 0);
/*system calls will be restarted if interrupted by the specified
* signal sig. This is the default behavior in Linux.
*/
#else
struct sigaction new_action,old_action;
memset(&new_action, 0, sizeof(struct sigaction));
/* Set up the structure to specify the new action. */
new_action.sa_handler = signal_handler;
if (sig==SIGINT)
sigemptyset (&new_action.sa_mask);
else
new_action.sa_flags = SA_RESTART /*| SA_NOCLDWAIT*/;
int r=si_sigaction (sig, &new_action, &old_action);
si_hdl_typ retval=(si_hdl_typ)old_action.sa_handler;
if (r == -1)
{
fprintf(stderr, "Unable to init signal %d ... exiting...\n", sig);
retval=SIG_ERR;
}
#endif
return retval;
} /* si_set_signal */
si_siginterrupt
#define si_siginterrupt(arg1, arg2)

## si_set_signals()

void si_set_signals | ( |  | ) |

Definition at line 560 of file cntrlc.cc.

{
//si_sigint_handler=si_set_signal(SIGINT ,(si_hdl_typ)sigint_handler);
old_sig_chld_hdl=si_sig_chld_hdl=si_set_signal(SIGCHLD, (si_hdl_typ)sig_chld_hdl);
//si_sig_pipe_hdl=si_set_signal(SIGPIPE, (si_hdl_typ)sig_pipe_hdl);
si_sig_term_hdl=si_set_signal(SIGTERM, (si_hdl_typ)sig_term_hdl);
}
si_sig_chld_hdl
VAR si_hdl_typ si_sig_chld_hdl
Definition cntrlc.cc:555

## sig_term_hdl()

void sig_term_hdl | ( | int |  | ) |

Definition at line 77 of file cntrlc.cc.

{
do_shutdown = TRUE;
if (!defer_shutdown)
{
m2_end(-1);
}
}
TRUE
#define TRUE
Definition auxiliary.h:101
do_shutdown
VAR volatile BOOLEAN do_shutdown
Definition cntrlc.cc:74
defer_shutdown
VAR volatile int defer_shutdown
Definition cntrlc.cc:75
m2_end
void m2_end(int i)
Definition misc_ip.cc:1104

## sig_term_hdl_child()

void sig_term_hdl_child | ( | int |  | ) |

Definition at line 86 of file cntrlc.cc.

{
_exit(0);
}

## Variable Documentation

## defer_shutdown

EXTERN_VAR volatile int defer_shutdown

Definition at line 23 of file cntrlc.h.

## do_shutdown

EXTERN_VAR volatile BOOLEAN do_shutdown

Definition at line 22 of file cntrlc.h.

## si_restart

EXTERN_VAR short si_restart

Definition at line 14 of file cntrlc.h.

## si_start_jmpbuf

EXTERN_VAR jmp_buf si_start_jmpbuf

Definition at line 13 of file cntrlc.h.

## singular_in_batchmode

EXTERN_VAR BOOLEAN singular_in_batchmode

Definition at line 18 of file cntrlc.h.

## siRandomStart

EXTERN_VAR int siRandomStart

Definition at line 15 of file cntrlc.h.