473,804 Members | 3,744 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

[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 sendKillsToChil dren()
{
int i;
for(i=0;i<nNVal ue;i++)
{
printf("sending kil to %d\n",childPids[i]);
kill(childPids[i],SIGINT);
}
}

void signalHandler(i nt dud)
{
printf("ctrl-c pressed\n");
printf("sendKil lsToChildren\n" );
sendKillsToChil dren();
}

int main()
{
signal(SIGINT,s ignalHandler);
int i;

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

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

while(1);
}

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

int main()
{
signal(SIGINT,s ignalHandler);
printf("in child process %d\n",getpid()) ;
}
Jul 22 '05 #1
2 1655
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
3513
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 read error: address 0xff3e70a0 not available dbx: warning: could not initialize librtld_db.so.1 -- trying libDP_rtld_db.so Make sure this is the same version of Solaris where the core dump
0
1311
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 problem is i want 2 different custom error handling files ,one for the main site and other for the admin.In the config file in admin I wrote <customErrors defaultRedirect="CustomErrorAdmin.aspx" mode="On" /> and in the other config file i wrote ...
8
1501
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 HELP ME.
6
2825
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. Note all this is included as text in the CSV file. I plan to read this csv file into a SQL 2000 DB using VB 2003. What data type should I use in the SQL DB? What data type should the variables be in VB? I will be adding and subtracting these...
3
3057
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 logic. In .Net 1.1, I create some events inside this class to notify WinForm the status of process: obj.OneFileStarted += new OneFileStartedEventHandler(obj_OneFileStarted); obj.OneFileFinished += new...
1
1679
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 Technologies Job Description Project Leader / APM required: Minimum 6 years experience out of which 2/3 years as PL / APM Education MCA / BE / Computer Science Graduates Technology - Microsoft VB / ASP .Net exposure
3
2256
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: gangadhar.sadhu@optionsindia.com Job Profile The company is looking for outstanding java, j2ee professionals with atleast 4 years experience in java,j2ee,xml,jsp,coding and
1
1361
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 facing the problem on the receiving fax part. I can know there have incoming queue fax. but after i input the number that i want the information, it become nothing and error come out. Thanks for view the post and giving comments. here's the code...
1
1938
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 question), and points out that ActiveX control is a pure client-side control, the server-side code cannot access this control (for your second question). Server-side code can access only server controls, which are the controls that are listed on the Web...
0
9706
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9577
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10075
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6847
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5519
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5651
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4295
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3815
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2990
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.