![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX and Linux Applications Discuss UNIX and Linux software applications. This includes SQL, Databases, Middleware, MOM, SOA, EDA, CEP, BI, BPM and similar topics. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| problem in SIGSEGV signal handling | pavan6754 | High Level Programming | 4 | 07-10-2009 06:33 AM |
| Signal handling | #moveon | High Level Programming | 1 | 05-27-2009 07:29 AM |
| signal handling question | fox_hound_33 | High Level Programming | 7 | 05-31-2008 01:53 PM |
| Program received signal SIGSEGV, Segmentation fault. | napapanbkk | High Level Programming | 5 | 06-30-2007 07:56 AM |
| Signal Handling | themezzaman | High Level Programming | 3 | 07-12-2006 10:05 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
First off, do not run code in production that gets a SIGSEGV signal. It is really bad practice.
The simplest way, and definitely not the best is to block the signal with a call to signal() Code:
#include <signal.h>
#include <stdio.h>
void my_signal_handler(int sig)
{
write(STDERR_FILENO, "SEGFAULT!\n", 10);
signal(SIGSEGV, my_signal_handler); // reset the signal handler for SIGSEGV
abort();
}
int main()
{
signal(SIGSEGV, my_signal_handler); // initial set of signal handler
/* do stuff here */
signal(SIGSEGV, SIG_DFL); // restore default behavior
}
|
|
||||
|
Quote:
Can you please explain this? Is it because of the reason, that kernel might possibly deliver SIGSEGV when using printf, but I guess that's possible even with write() - I think am wrong. |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|