WNOHANG in SIGCHLD handler
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 > WNOHANG in SIGCHLD handler




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

    WNOHANG in SIGCHLD handler  
Roman Mashak


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


 
03-14-06 07:49 AM

Hello, All!

I can't grasp the point of using WNOHANG in 'waitpid()', when it's called
inside of handler reaping children? According to man page WNOHANG 'means to
return immediately if no child has exited', but if the handler was invoked,
the signal has already been sent, right?

With best regards, Roman Mashak.  E-mail: mrv@tusur.ru







[ Post a follow-up to this message ]



    Re: WNOHANG in SIGCHLD handler  
Nils O. Selåsdal


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


 
03-14-06 07:49 AM

Roman Mashak wrote:
> Hello, All!
>
> I can't grasp the point of using WNOHANG in 'waitpid()', when it's called
> inside of handler reaping children? According to man page WNOHANG 'means t
o
> return immediately if no child has exited', but if the handler was invoked
,
> the signal has already been sent, right?
This is to ensure you collect all children.
unix signals doesn't queue - if more than one child died at about
the same time that might result in just one SIGCHLD.
Thus you should call waitpid in a loop to be sure you reap all of them.





[ Post a follow-up to this message ]



    Re: WNOHANG in SIGCHLD handler  
Roman Mashak


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


 
03-14-06 07:49 AM

Hello, "Nils!
You wrote  on Tue, 14 Mar 2006 08:22:53 +0100:

??>> I can't grasp the point of using WNOHANG in 'waitpid()', when it's
??>> called inside of handler reaping children? According to man page
??>> WNOHANG 'means to return immediately if no child has exited', but if
??>> the handler was invoked, the signal has already been sent, right?
NOS> This is to ensure you collect all children.
NOS> unix signals doesn't queue - if more than one child died at about
NOS> the same time that might result in just one SIGCHLD.
If it may result in only one SIGCHLD, what happens with other children
signals from which I didn't receive?
NOS> Thus you should call waitpid in a loop to be sure you reap all of
NOS> them.

With best regards, Roman Mashak.  E-mail: mrv@tusur.ru







[ Post a follow-up to this message ]



    Re: WNOHANG in SIGCHLD handler  
Nils O. Selåsdal


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


 
03-14-06 12:49 PM

Roman Mashak wrote:
> Hello, "Nils!
> You wrote  on Tue, 14 Mar 2006 08:22:53 +0100:
>
>  ??>> I can't grasp the point of using WNOHANG in 'waitpid()', when it's
>  ??>> called inside of handler reaping children? According to man page
>  ??>> WNOHANG 'means to return immediately if no child has exited', but if
>  ??>> the handler was invoked, the signal has already been sent, right?
>  NOS> This is to ensure you collect all children.
>  NOS> unix signals doesn't queue - if more than one child died at about
>  NOS> the same time that might result in just one SIGCHLD.
> If it may result in only one SIGCHLD, what happens with other children
> signals from which I didn't receive?

They are merged with the one you did receive.





[ Post a follow-up to this message ]



    Re: WNOHANG in SIGCHLD handler  
David Schwartz


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


 
03-14-06 12:49 PM


"Roman Mashak" <mrv@tusur.ru> wrote in message
news:dv5ndg$2g8b$1@relay.tomsk.ru...

> Hello, All!
>
> I can't grasp the point of using WNOHANG in 'waitpid()', when it's called
> inside of handler reaping children? According to man page WNOHANG 'means
> to return immediately if no child has exited', but if the handler was
> invoked, the signal has already been sent, right?

Sure, but how many times? Perhaps the first time you don't need WNOHANG,
but then you need to check if another child has exited, and you don't know
for sure whether one has or not.

DS







[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 03:36 AM.      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