473,396 Members | 1,998 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,396 software developers and data experts.

[URGENT]Signal Handling

Hi,

I have a program that fork()'s + execlp()'s two children. Later in the
program I want to send a signal to the parent(SIGINT) . The parent's signal
handler should then send signals to these two children. I am able to catch
the signal in the parent - on catching this signal I invoke a function that
sends kill(childPid[i],SIGINT) but the signal handler in the child doesn't
seem to be getting invoked. Can someone please tell me why this is
happenning? Since this is kind of urgent I would greatly appreciate a speedy
response. Thanks a lot!

I am including the code below - first the parent's and following that the
child's

Parent code:
void sendKillsToChildren()
{
int i;
for(i=0;i<nNValue;i++)
{
printf("sending kil to %d\n",childPids[i]);
kill(childPids[i],SIGINT);
}
}

void signalHandler(int dud)
{
printf("ctrl-c pressed\n");
printf("sendKillsToChildren\n");
sendKillsToChildren();
}

int main()
{
signal(SIGINT,signalHandler);
int i;

childPids=(int*)malloc(nNValue*sizeof(pid_t));

for(i=0;i<2;i++)
{
switch(childPids[i]=fork())
{
case -1:
//Error
perror("Error in fork() in godclass::forkOne()");
break;
case 0:
//In Child
execlp("child.o",0);
break;
default:
//In parent
printf("child[%d]=%d\n",i,childPids[i]);
break;
}
}

while(1);
}

Child code:
void signalHandler(int dud)
{
printf("recvd signal in %d\n",getpid());
}

int main()
{
signal(SIGINT,signalHandler);
printf("in child process %d\n",getpid());
}
Jul 22 '05 #1
2 1637
Rookie wrote:
I have a program that fork()'s + execlp()'s two children.


fork()-ing and execlp()-ing are beyond the scope of a language newsgroup.
You need to ask in a newsgroup where these things are topical. Like an NG
dedicated to your OS.

V
Jul 22 '05 #2
Rookie wrote:
Hi,

I have a program that fork()'s + execlp()'s two children. Later in the
program I want to send a signal to the parent(SIGINT) . The parent's signal
handler should then send signals to these two children.


Are you sure you issued the "signal" to catch the signal in the exec'd
program "cihld.o"? Signals set to be caught by functions (as opposed
to default (SIG_DFL) or ignore (SIG_IGN) are reset to the default action.
How can it catch a signal into a handler that doesn't exist any more.
Jul 22 '05 #3

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

Similar topics

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...
0
by: Kamal Dhingra | last post by:
Hi Guys, I am developing an asp.net application .In error handling , I have 2 web.congif files ,one is in Web(which is the virtual directory) ,other i have created in a folder in Web/Admin. The...
8
by: Prince Mathew | last post by:
Hi All, I have a requirement. I am throwing an exception from my user control I want to catch this in my container page. Is this possible? I don't want any event to be raised. PLEASE...
6
by: cj | last post by:
I have a comma delimited file with 2 numeric columns. The first is just a decimal number that seems to have a max of 1 decimal place. The last column is money BUT very tiny increments of money. ...
3
by: Hardy Wang | last post by:
Hi all, I am migrating a Windows Form application from .Net 1.1 to 2.0. I try to use BackgroundWorker object to handle a very lengthy process. I have a separated class to handle some very complex...
1
by: optionsindia | last post by:
hi, we are having urgent requirement for one of our client cmmi level5 company in hyd and chennai. if u r intrested send me ur updated resume gangadhar.sadhu@optionsindia.com Skill Microsoft...
3
by: optionsindia | last post by:
hi partners, we are having a urgent requirement for java architect with our clients located at chennai,hyderabad and bangalore if u r intrested send u r updated resume mail to:...
1
by: zeuscc | last post by:
I'm doing my final year project which is web-based fax server. I'm using the faxcomexlib library that inside the visual studio 2005 to do the fax function. I had done the send fax part. But now i...
1
by: Jialiang Ge [MSFT] | last post by:
Hello Philippe, In addition to bruce's points, I'd suggest the KB article http://support.microsoft.com/kb/317392. It demonstrates how to host an ActiveX control in ASP.NET (for your first...
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: 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?
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.