linux-c-programming.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Signals And Chlidren
@ 2004-07-05 19:17 Eric Bambach
  2004-07-06  0:37 ` Glynn Clements
  0 siblings, 1 reply; 4+ messages in thread
From: Eric Bambach @ 2004-07-05 19:17 UTC (permalink / raw)
  To: linux-c-programming

Hello,

	I am now trying to learn about signals and signal handling and I have the 
following situation. 

Main program-
	Child of main-
		1st grandchild
		2nd grandchild

These are children created by fork() and the grandchildren are created by 
fork() exec(). I need a method to send SIGTERM to only the children and not 
to a whole process group. Specifically, I have a rather obvious problem 
problem using the code below. When I use teh command
#kill (pid of child of main)
The program spits MANAGER CAUGHT TERM for quite a while until it causes the 
whole program to exit. However, I think my code has more problems because I 
thought SIGTERM would be blocked in a SIGTERM handler, isnt it?

Most of the documentation I have read indicates that signal handlers cannot be 
interrupted by the signals they are handling unless otherwise specified, 
however the long loop of CAUGHT TERM messages indicates otherwise.

Is there any way to send signals to ONLY the children without having to 
explicitly know their PID? 

If the child recieves SIGTERM, I want to SIGTERM the grandchildren to make 
sure they stop+cleanup instead of continuing and being reparented to init.

I probably have other problems too ;). Let me know if you need more 
information.
-----------------CODE-------------

void SigTermHandler(int value)
{

#ifdef DEBUG
  cerr << "MANAGER CAUGHT TERM" << endl;
#endif
  kill((pid_t)0,SIGTERM); 
}
-----------------END CODE-------------

Thank you for your time.

-- 
-EB

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2004-07-06  5:28 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-07-05 19:17 Signals And Chlidren Eric Bambach
2004-07-06  0:37 ` Glynn Clements
2004-07-06  3:33   ` Eric Bambach
2004-07-06  5:28     ` Glynn Clements

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).