473,386 Members | 1,823 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Sig handler causing core dump

I'm a newbie to C programming...so go easy. ;)
I'm forking child processes, and registering a signal handler with the following:
signal(SIGTERM, DieServer);
signal(SIGINT, DieServer);

DieServer is the following:
volatile sig_atomic_t dying_in_progress = 0;
void DieServer(int sig){
int result;
char dummy[0];
if(dying_in_progress) raise(sig);
dying_in_progress = 1;

// Now do the clean up actions:
if(debug==1) printf("SERVER PARENT->Received SIGEVENT %d.\n",sig);
wait();
close(client_sockfd);
read(server_sockfd,dummy,0);
result = close(server_sockfd);
if(result==-1){
if(debug==1) printf("SERVER PARENT->Could not close socket\n");
perror("WARNING");
}
signal(sig, SIG_DFL);
raise(sig);
}

The wait() causes a core dump if there's no children. How do I fix this?
Nov 14 '05 #1
3 2285
Mark Brackett wrote:
I'm a newbie to C programming...so go easy. ;)
OK. I'll be gentle.
I'm forking child processes, and registering a signal handler with the following:
Whoops. There is no such thing as `forking' in standard C...
signal(SIGTERM, DieServer);
signal(SIGINT, DieServer);

DieServer is the following:
volatile sig_atomic_t dying_in_progress = 0;
void DieServer(int sig){
int result;
char dummy[0];
if(dying_in_progress) raise(sig);
dying_in_progress = 1;

// Now do the clean up actions:
if(debug==1) printf("SERVER PARENT->Received SIGEVENT %d.\n",sig);
wait();
close(client_sockfd);
read(server_sockfd,dummy,0);
result = close(server_sockfd);
if(result==-1){
if(debug==1) printf("SERVER PARENT->Could not close socket\n");
perror("WARNING");
}
signal(sig, SIG_DFL);
raise(sig);
}

The wait() causes a core dump if there's no children. How do I fix this?

....nor read(), nor close() nor wait().

There *are* such things in POSIX, hence posting your question to
news:comp.unix.programmer would be the best course of action.

Gentle enough for you? ;-)

See you over there.

HTH,
--ag

--
Artie Gold -- Austin, Texas

http://it-matters.blogspot.com
Nov 14 '05 #2
In article <de**************************@posting.google.com >,
Mark Brackett <br******@ufl.edu> wrote:
I'm a newbie to C programming...so go easy. ;)
I'm forking child processes, <snip>The wait() causes a core dump if there's no children. How do I fix this?


forking child processes, wait(), and a lot of what was in between that I
snipped are beyond the scope of the C language and therefore inappropriate
for comp.lang.c.

I suspect that comp.unix.programmer would be a better place to ask this.
dave

--
Dave Vandervies dj******@csclub.uwaterloo.ca
Hmm, a quote for posterity: "calling strlen() is a lengthy operation."
Is calling memmove() a 'moving experience?'
--Mike Wahler in comp.lang.c
Nov 14 '05 #3
dj******@csclub.uwaterloo.ca (Dave Vandervies) wrote in message news:<cm**********@rumours.uwaterloo.ca>...
In article <de**************************@posting.google.com >,
Mark Brackett <br******@ufl.edu> wrote:
I'm a newbie to C programming...so go easy. ;)
I'm forking child processes,

<snip>
The wait() causes a core dump if there's no children. How do I fix this?


forking child processes, wait(), and a lot of what was in between that I
snipped are beyond the scope of the C language and therefore inappropriate
for comp.lang.c.

I suspect that comp.unix.programmer would be a better place to ask this.
dave


Doh! Sorry for the faux pas....I'll try again over there. Thanks for
the gently delivered heads-ups.

--Mark Brackett
Nov 14 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Xaver Hinterhuber | last post by:
Hello pythonistas, I build a function with the following code segment: codeObject = new.code( 0, # argcount 0, # nlocals 0, # stacksize 0, # flags codeString, # code
1
by: Martin | last post by:
I use dbx and i got the following error: Reading GL_CliConnMgr core file header read successfully Reading ld.so.1 dbx: core file read error: address 0xff3e6000 not available dbx: core file...
10
by: ken | last post by:
hello, i'm writing a c program on a linux system. i'm debugging a segmentation fault but i don't want it to dump a core file because the memory footprint of the program is over 300Mb and i don't...
0
by: Anonieko Ramos | last post by:
Answer. Use IHttpHandler. thanks Ro ry for coming up with this code. It processes css file to add variables. neat idea using System; using System.IO; using System.Text; using...
10
by: John Liu | last post by:
We upgraded from 7.2 to 7.4, it looks like everything working, but when I issue a query such as select * from tab (tab has about 2-3 million records), it causes core dump. I tuned some the...
3
by: John Liu | last post by:
AIX pg version 7.4 Select * from document2 core dump. Did a few more experiments with select * from document2 limit... I limit to 500000 it works, 600000 it exits but says "calloc:...
10
by: wong_powah | last post by:
I want to find out where (which line) my C program core dump. How to do that? Is there a web site describing the procedure? One approach is to use stack trace of the mdb debugger, but I does not...
2
by: Achint Mehta | last post by:
Hi, I am running purify on my program (on linux with gcc ver. 3.4.6) I have installed a signal handler (for timer) using sigaction. I am passing a pointer (data) into the sival_ptr which I...
5
by: johnericaturnbull | last post by:
Hi - I am very new to python. I get this random core dump and am looking for a good way to catch the error. I know the function my core dump occurs. Is there any error catching/handling that I...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.