finalint
16-03-2007, 11:20
ciao, non mi è molto chiaro un aspetto sulla gestione dei segnali..
mi potete dare una mano!?
usando un costrutto del genere posso catturare un segnale e
eseguire una funzione di "gestione" del segnale che ho catturato..
#include <signal.h>
...
void gestoreKill()
{
//eseguita quando viene ricevuto un kill
signal(SIGKILL, gestoreKill);
...
}
...
int main()
{
//Inizializza l'azione assegnata al segnale SIGKILL
signal(SIGKILL, gestoreKill);
...
}
però non ho dove devo andare per trovare il codice esatto dell'errore..
questi:
249 /* codes for SIGSEGV */
250 #define SEGV_MAPERR 1 /* Address not mapped to object. */
251 #define SEGV_ACCERR 2 /* Invalid permissions for mapped */
252 /* object. */
253
254 /* codes for SIGFPE */
255 #define FPE_INTOVF 1 /* Integer overflow. */
256 #define FPE_INTDIV 2 /* Integer divide by zero. */
257 #define FPE_FLTDIV 3 /* Floating point divide by zero. */
258 #define FPE_FLTOVF 4 /* Floating point overflow. */
259 #define FPE_FLTUND 5 /* Floating point underflow. */
260 #define FPE_FLTRES 6 /* Floating point inexact result. */
261 #define FPE_FLTINV 7 /* Invalid floating point operation. */
262 #define FPE_FLTSUB 8 /* Subscript out of range. */
263
264 /* codes for SIGTRAP */
265 #define TRAP_BRKPT 1 /* Process breakpoint. */
266 #define TRAP_TRACE 2 /* Process trace trap.
se io catturo SIGTRAP come faccio a capire se è TRAP_BRKPT o TRAP_TRACE?!
mi potete dare una mano!?
usando un costrutto del genere posso catturare un segnale e
eseguire una funzione di "gestione" del segnale che ho catturato..
#include <signal.h>
...
void gestoreKill()
{
//eseguita quando viene ricevuto un kill
signal(SIGKILL, gestoreKill);
...
}
...
int main()
{
//Inizializza l'azione assegnata al segnale SIGKILL
signal(SIGKILL, gestoreKill);
...
}
però non ho dove devo andare per trovare il codice esatto dell'errore..
questi:
249 /* codes for SIGSEGV */
250 #define SEGV_MAPERR 1 /* Address not mapped to object. */
251 #define SEGV_ACCERR 2 /* Invalid permissions for mapped */
252 /* object. */
253
254 /* codes for SIGFPE */
255 #define FPE_INTOVF 1 /* Integer overflow. */
256 #define FPE_INTDIV 2 /* Integer divide by zero. */
257 #define FPE_FLTDIV 3 /* Floating point divide by zero. */
258 #define FPE_FLTOVF 4 /* Floating point overflow. */
259 #define FPE_FLTUND 5 /* Floating point underflow. */
260 #define FPE_FLTRES 6 /* Floating point inexact result. */
261 #define FPE_FLTINV 7 /* Invalid floating point operation. */
262 #define FPE_FLTSUB 8 /* Subscript out of range. */
263
264 /* codes for SIGTRAP */
265 #define TRAP_BRKPT 1 /* Process breakpoint. */
266 #define TRAP_TRACE 2 /* Process trace trap.
se io catturo SIGTRAP come faccio a capire se è TRAP_BRKPT o TRAP_TRACE?!