Hi Robert:

   Thanks a lot for your kind reply.
   It makes sense to me now. Just one more question to fully clarify this matter. From 
the description from man page. I have feeling that I have to set the value of pid to 
"0" - which means to wait for any child process whose process group ID is equal to 
that of  the  calling  process. Meaning my program only wait for the specific child 
processes forked by the parent process. Of course I should take out the "WNOHANG". 
   What it happened here is the typical problem while some one  inherit code from some 
existing source and  without fully understanding what exactly the effect of the 
function is. I learn new things every day. I really appreciate your guide. This user 
group list really beneficial to a lot people. You and many others generosity and the 
valuable offering really can't be measured by the material object. I deeply appreciate 
all your help.

-Jim 

-----Original Message-----
From: Robert Story (Users) [mailto:[EMAIL PROTECTED]
Sent: Thursday, September 23, 2004 3:18 AM
To: Jim Su
Cc: [EMAIL PROTECTED]
Subject: Re: waitpid for child processes invoked from agent


On Mon, 20 Sep 2004 12:30:35 +0800 Jim wrote:
JS>     I do have the waitpid() routine inside the sa_handler of the daemon
JS>     which the snmpd get value from. The waitpid is as following - if
JS>     (waitpid(-1, &status, WNOHANG) < 0) { return; }

That is your problem. WNOHANG means don't wait for a child that hasn't exited
yet, and will return immediately if the child is still running. And specifying
a parameter of -1 will wait for any child, not necessarily the one you just
ran. Either take out WNOHANG to actually wait for the child to complete, or
periodically call waitpid as you do above to reap defunct processes.


-- 
Robert Story; NET-SNMP Junkie <http://www.net-snmp.org/>
<irc://irc.freenode.net/#net-snmp>  
Archive: <http://sourceforge.net/mailarchive/forum.php?forum=net-snmp-users>

You are lost in a twisty maze of little standards, all different. 

Reply via email to