Kill Process Group
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Unix and Linux reviews > Free Unix support > Unix Programming > Kill Process Group




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    Kill Process Group  
Michael B Allen


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
07-16-05 01:52 AM

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






[ Post a follow-up to this message ]



    Re: Kill Process Group  
Barry Margolin


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
07-17-05 01:47 AM

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 ***





[ Post a follow-up to this message ]



    Re: Kill Process Group  
Barry Margolin


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
07-17-05 01:47 AM

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 ***





[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 01:02 PM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register