Advance singal handling in C

Advance singal handling in C

Post by M.chandrasekha » Fri, 04 Jul 2003 14:42:36



Hi,
     Any one has idea of how to handle signaling in program run time errors.
I mean not just signal handler..i want to know the exact reason of error.
Well "extern int errno" is not updated when an abrupt signal is thrown like
SIGSEGV etc..example. like we use gdb and find out with registers where
error of memory occured can't we handle that in program itself..

We can register signal handler but its (void (*)(int)) where we can only
obtain signal number and my question is how to trap the exact error of that
signal..

-Regards
chandra

 
 
 

Advance singal handling in C

Post by Fletcher Glen » Wed, 09 Jul 2003 00:57:36



> Hi,
>      Any one has idea of how to handle signaling in program run time errors.
> I mean not just signal handler..i want to know the exact reason of error.
> Well "extern int errno" is not updated when an abrupt signal is thrown like
> SIGSEGV etc..example. like we use gdb and find out with registers where
> error of memory occured can't we handle that in program itself..

> We can register signal handler but its (void (*)(int)) where we can only
> obtain signal number and my question is how to trap the exact error of that
> signal..

> -Regards
> chandra

You really have to be careful what you attempt to do in a signal
handler, especially when the signal indicates that the heap
or the stack has been compromised.  In those circumstances,
it may be impossible to do anything meaningful to recover from
the error, and it may be very difficult to even output indications
of the program failure.  The difficulty in this latter case is that
many of the output routines like printf and cout use memory allocation
which may cause more errors if the heap is corrupted.

--
                Fletcher Glenn


 
 
 

Advance singal handling in C

Post by Chuck Dillo » Wed, 09 Jul 2003 02:27:45



> Hi,
>      Any one has idea of how to handle signaling in program run time errors.
> I mean not just signal handler..i want to know the exact reason of error.
> Well "extern int errno" is not updated when an abrupt signal is thrown like
> SIGSEGV etc..example. like we use gdb and find out with registers where
> error of memory occured can't we handle that in program itself..

> We can register signal handler but its (void (*)(int)) where we can only
> obtain signal number and my question is how to trap the exact error of that
> signal..

> -Regards
> chandra

man siginfo and sigaction

-- ced

--
Chuck Dillon
Senior Software Engineer
NimbleGen Systems Inc.

 
 
 

1. Any advanced resource on how ksh handles signals?

Can anyone point me to an advanced resource to learn how ksh handles
signals?  I have all the standard books and can find nothing which
discusses this.  If it's in the manpages, I can't find it.

For example, why does ksh delay the handling of the TERM signal in the
following script:

$ cat testme
#!/bin/ksh
trap "echo GOT TERM" TERM
/bin/sleep 60
$ ./testme &
[1]     8364046
$ kill -TERM 8364046
... (60 seconds later -- why this delay?) ...
$ GOT TERM
[1] +  Done                    ./testme &

I would have thought that the script would have echoed the message
immediately.  I know I can use kill -TERM %% instead to end it
immediately (by sending a signal to the process group?) but the details
on what's really going on seem to be hard to locate.  And what if I'm
sending the signal from another, unrelated session (in another window,
say)?  Then how could I send the signal to the equivalent of the %%
job?

Thanks!
-- John Wiersba

2. how to boot w/o KBD

3. SINGAL bad. ? linux bug ?

4. Setting Up Quake & Quake II

5. GCC singal 11 caught?

6. Virtual/Software UART?

7. cannot find include file: <singal.h>

8. Cdrecord- Why does not it work?

9. Caught singal error message

10. SINGAL FAILS !!!

11. How to issue a Control ] singal in a shell script

12. Safe Singal Handlers

13. How to issue a Control ] singal in a shell script