From: Eric Bambach <eric@cisu.net>
To: linux-c-programming@vger.kernel.org
Subject: Signals And Chlidren
Date: Mon, 5 Jul 2004 14:17:03 -0500 [thread overview]
Message-ID: <200407051417.03410.eric@cisu.net> (raw)
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
next reply other threads:[~2004-07-05 19:17 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-07-05 19:17 Eric Bambach [this message]
2004-07-06 0:37 ` Signals And Chlidren Glynn Clements
2004-07-06 3:33 ` Eric Bambach
2004-07-06 5:28 ` Glynn Clements
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200407051417.03410.eric@cisu.net \
--to=eric@cisu.net \
--cc=linux-c-programming@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).