LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 11-07-2005, 04:02 AM   #1
Thinking
Member
 
Registered: Oct 2003
Posts: 249

Rep: Reputation: 30
how to log segmentation fault in forked child


hiho@ll

if i do a fork();
and my child does a segmentation fault
how can i recognize this?

as far as i know if a child from the apache server does a segfault you get a line in the apache error log

and i know from windows you can perform your own crash functions if your app crashes so you can email yourself a error report

is something similiar possible under linux?
how do i recognize a segfault
is it possible to get a backtrace?

thx@ll
 
Old 11-07-2005, 06:45 AM   #2
Wim Sturkenboom
Senior Member
 
Registered: Jan 2005
Location: Roodepoort, South Africa
Distribution: Slackware 10.1/10.2/12, Ubuntu 12.04, Crunchbang Statler
Posts: 3,786

Rep: Reputation: 282Reputation: 282Reputation: 282
Code:
// example signal handler for segfaults
void handle_sigsegv(int segnum)
{
  fprintf(stderr,"Signal SIGSEGV (%d) received", signum);
  _exit(0);
}
Code:
// install a handler for SIGSEGV in a part of your code
if(signal(SIGSEGV,&handle_sigsegv)==SIG_ERR)
{
  fprintf(stderr,"Could not install SIGSEGV handler");
  return -1;
}

Last edited by Wim Sturkenboom; 11-07-2005 at 06:48 AM.
 
Old 11-07-2005, 08:55 AM   #3
Thinking
Member
 
Registered: Oct 2003
Posts: 249

Original Poster
Rep: Reputation: 30
hmm

didn't thought it would work with signals

thx
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
yast segmentation fault, system freezing - nvidia driver at fault? BaltikaTroika SUSE / openSUSE 2 12-02-2005 09:34 AM
Segmentation fault tejas15_10 Programming 9 06-20-2005 09:12 AM
[notice] child pid 1296 exit signal Segmentation fault (11) Bigtimelost Linux - General 2 04-13-2004 12:38 PM
Apache: child pid XXX exit signal Segmentation fault (11) gabriele_101 Linux - Hardware 1 07-23-2003 06:12 PM
segmentation fault ! wwnn1 Programming 7 06-18-2002 09:48 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:19 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration