|
Home > Archive > Unix Programming > July 2005 > Kill Process Group
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Kill Process Group
|
|
| Michael B Allen 2005-07-15, 8:52 pm |
| In the signal handler for my daemon processes I want to kill all processes
when I get SIGQUIT. Currently I catch SIGQUIT and issue:
kill(-process_group, SIGABRT);
However this requires that I know the process group value. Is there
a sure-fire way to get the process group id from within a signal
handler? Would the following be suitable?
killpg(0, SIGABRT);
Thanks,
Mike
| |
| Barry Margolin 2005-07-16, 8:47 pm |
| In article <pan.2005.07.16.02.00.11.544713@ioplex.com>,
Michael B Allen <mba2000@ioplex.com> wrote:
> In the signal handler for my daemon processes I want to kill all processes
> when I get SIGQUIT. Currently I catch SIGQUIT and issue:
>
> kill(-process_group, SIGABRT);
>
> However this requires that I know the process group value. Is there
> a sure-fire way to get the process group id from within a signal
> handler? Would the following be suitable?
The top-most process of the daemon should establish itself as the
process group leader, so process_group == PID.
>
> killpg(0, SIGABRT);
Yes, that should work as well. 0 means to send to the current process's
group.
--
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
| |
| Barry Margolin 2005-07-16, 8:47 pm |
| In article <pan.2005.07.16.02.00.11.544713@ioplex.com>,
Michael B Allen <mba2000@ioplex.com> wrote:
> In the signal handler for my daemon processes I want to kill all processes
> when I get SIGQUIT. Currently I catch SIGQUIT and issue:
>
> kill(-process_group, SIGABRT);
>
> However this requires that I know the process group value. Is there
> a sure-fire way to get the process group id from within a signal
> handler? Would the following be suitable?
The top-most process of the daemon should establish itself as the
process group leader, so process_group == PID.
>
> killpg(0, SIGABRT);
Yes, that should work as well. 0 means to send to the current process's
group.
--
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
|
|
|
|
|