#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <sys/types.h>
#include <imu_stim300/Stim300RevD.hpp>
#include <imu_stim300/Stim300RevB.hpp>
|
| typedef void(* | handling_t) (int sig, void *data) |
| | POINTER TO HANDLING FUNCTION. More...
|
| |
◆ handling_t
| typedef void(* handling_t) (int sig, void *data) |
POINTER TO HANDLING FUNCTION.
SIGNAL ID DEFAULT DESCRIPTION
SIGHUP 1 Termin. Hang up on controlling terminal SIGINT 2 Termin. Interrupt. Generated when we enter CNRTL-C and it is delivered to all processes/threads associated to the current terminal. If generated with kill, it is delivered to only one process/thread. SIGQUIT 3 Core Generated when at terminal we enter CNRTL-\ SIGILL 4 Core Generated when we executed an illegal instruction SIGTRAP 5 Core Trace trap (not reset when caught) SIGABRT 6 Core Generated by the abort function SIGFPE 8 Core Floating Point error SIGKILL 9 Termin. Termination (can't catch, block, ignore) SIGBUS 10 Core Generated in case of hardware fault SIGSEGV 11 Core Generated in case of illegal address SIGSYS 12 Core Generated when we use a bad argument in a system service call SIGPIPE 13 Termin. Generated when writing to a pipe or a socket while no process is reading at other end SIGALRM 14 Termin. Generated by clock when alarm expires SIGTERM 15 Termin. Software termination signal SIGURG 16 Ignore Urgent condition on IO channel SIGCHLD 20 Ignore A child process has terminated or stopped SIGTTIN 21 Stop Generated when a backgorund process reads from terminal SIGTTOUT 22 Stop Generated when a background process writes to terminal SIGXCPU 24 Discard CPU time has expired SIGUSR1 30 Termin. User defiled signal 1 SIGUSR2 31 Termin. User defined signal 2
- Author
- Javier Hidalgo Carrio . Defines for the signaling library. Definitiod of data type for pointer to handling function
◆ main()
| int main |
( |
int |
argc, |
|
|
char ** |
argv |
|
) |
| |
◆ signal_catcher()
| bool signal_catcher |
( |
int |
sig_1, |
|
|
int |
sig_2, |
|
|
int |
sig_3, |
|
|
int |
sig_4, |
|
|
handling_t |
pfunc, |
|
|
void * |
values |
|
) |
| |
The Function catchs the signal introduced in the parameter of this function.
The function associates the signals with the handling function to be handled when the process would receives such signal from the operating system. The handling function should have two parameters when defined in the main program. one parameter (integer) for the signal number, another for the pointer to void (values) Normally the last one is a pointer to a structure.
- Author
- Javier Hidalgo Carrio.
- Parameters
-
| [in] | sig_1 | integer for the number of signal 1 to be handled |
| [in] | sig_2 | integer for the number of signal 2 to be handled |
| [in] | sig_3 | integer for the number of signal 3 to be handled |
| [in] | sig_4 | integer for the number of signal 4 to be handled |
| [in] | pfunc | pointer to the handling function |
| [in] | values | pointer to void, the parameter of the handling function. |
- Returns
- OK is everything all right. ERROR in other cases
◆ signal_set()
| bool signal_set |
( |
int |
sig, |
|
|
handling_t |
pfunc, |
|
|
void * |
values |
|
) |
| |
Function that set a defined handler for a signal.
- Author
- Javier Hidalgo Carrio.
- Parameters
-
| [in] | sig | integer for the number of signal to be handled |
| [in] | pfunc | pointer of the handling function |
| [in] | values | pointer of void, the parameter of the handling function. |
- Returns
- OK is everything all right. ERROR on other cases
◆ signal_terminator()
| void signal_terminator |
( |
int |
sig, |
|
|
void * |
values |
|
) |
| |
Function for handling system signals.
This function is the handler when the catched system signal happen.
- Author
- Javier Hidalgo Carrio.
- Parameters
-
| [in] | sig | integer of the catched signal |
| [in] | values | pointer of void (pointer of the IMU structure after casting in the function) |
- Returns
- void