Hello all,
subject: sipp defunct processes
I'm using sipp for a while now (on linux), and wanted to generate some syslog messages when things go wrong with the SUT.
As no syslog functionality is built in, I started calling the external program logger, and I noticed the same behaviour as found with google and copied here below (between the dashes): hanging defunct child processes.
As I only subscribed the mailing list a few days ago and google didn't indicate a solution to this problem yet, I hope I'm not too late with this contribution.
Now, I'm a (very;-) old programmer from the time C++ was not yet really used, I found rather quickly what was the problem, but it's somewhat hard for me to put all pieces correctly in the code. So I made a description how to solve this problem, hoping somebody knowing his way in the sipp code but knowing less about unix process handling can easily add it. You can find the description below Harry's mail, based on the code version 1.1rc6.
Best regards,
MarcVD
---------------------------------------------
Rarig, Harry
Tue, 26 Sep 2006 12:21:36 -0700
While doing some simple call testing with an "exec" action below
<recv response="200" rtd="true">
<action>
<exec command="echo Got 200 OK > foo"/>
</action>
</recv>
I noticed that after the SIPp process ran through several iterations, it began to accumulate "defunct" processes in the LINUX process table (both Fedora Core 5 and RH 9.0). Eventually, after SIPp ran through a few hundred calls, the proc table was full and the SIPp process failed with the error message "cannot fork".
If the "exec" action is pulled, SIPp works fine and the defunct processes go away. The behavior is the same even if the "action" block is moved inside a "nop" command.
Any idea how the "exec" action can be controlled to avoid this nasty accumulation of defunct process?
Much tnx,
Harry
[EMAIL PROTECTED] ~]$ ps -al
F S UID PID PPID C PRI NI ADDR SZ WCHAN TTY TIME CMD
4 S 0 5377 4946 0 77 0 - 1276 - pts/5 00:00:00 su
4 S 0 5380 5377 0 75 0 - 1072 - pts/5 00:00:00 bash
4 S 0 6845 5444 0 76 0 - 1203 - pts/1 00:00:00 su
4 S 0 6848 6845 0 75 0 - 1392 - pts/1 00:00:00 bash
0 S 502 7589 7385 0 75 0 - 6601 - pts/6 00:00:00 sipp
0 S 502 7752 7595 0 75 0 - 6548 - pts/7 00:00:00 sipp
1 Z 502 7755 7752 0 76 0 - 0 exit pts/7 00:00:00 sipp <defunct>
1 Z 502 7757 7752 0 76 0 - 0 exit pts/7 00:00:00 sipp <defunct>
1 Z 502 7759 7752 0 76 0 - 0 exit pts/7 00:00:00 sipp <defunct>
1 Z 502 7761 7752 0 76 0 - 0 exit pts/7 00:00:00 sipp <defunct>
1 Z 502 7765 7752 0 76 0 - 0 exit pts/7 00:00:00 sipp <defunct>
1 Z 502 7767 7752 0 77 0 - 0 exit pts/7 00:00:00 sipp <defunct>
1 Z 502 7776 7752 0 77 0 - 0 exit pts/7 00:00:00 sipp <defunct>
1 Z 502 7778 7752 0 76 0 - 0 exit pts/7 00:00:00 sipp <defunct>
1 Z 502 7790 7752 0 76 0 - 0 exit pts/7 00:00:00 sipp <defunct>
1 Z 502 7792 7752 0 76 0 - 0 exit pts/7 00:00:00 sipp <defunct>
1 Z 502 7809 7752 0 76 0 - 0 exit pts/7 00:00:00 sipp <defunct>
1 Z 502 7812 7752 0 76 0 - 0 exit pts/7 00:00:00 sipp <defunct>
1 Z 502 7823 7752 0 76 0 - 0 exit pts/7 00:00:00 sipp <defunct>
1 Z 502 7826 7752 0 76 0 - 0 exit pts/7 00:00:00 sipp <defunct>
1 Z 502 7839 7752 0 76 0 - 0 exit pts/7 00:00:00 sipp <defunct>
1 Z 502 7841 7752 0 76 0 - 0 exit pts/7 00:00:00 sipp <defunct>
0 R 502 7854 7636 0 77 0 - 841 - pts/8 00:00:00 ps
[EMAIL PROTECTED] ~]$ ps -al
------------------------------------------------------------------
my small contribution:
-----------------------
In Unix, somewhere in the code, the parent process should wait for the child process to be finished. Using grep, I could easily find the "system(x)" in the forked child, but apparently the parent doesn't "wait" for the forked child.
This waiting is done via code looking like this, to be inserted somewhere in the main program loop where you pass often enough (the basic cycle should be OK):
/*** general variable ***/
int nchildren=0;/* the number of child processes not yet handled */
/*** code to insert in main loop ***/
#include <sys/wait.h>
pid_t pid;
while (nchildren>0) {/* loop as long as there are children */
pid=waitpid(-1,(int *)NULL,WNOHANG);/* wait for any child only if it's ready */
if (pid==0) break; /* no more child ready */
nchildren-=1;/* there was one ready */
}
/*** adapted code when lauching your child in call.cpp ***/
// TRACE_MSG((s, "Trying to execute [%s]", x));
pid_t l_pid;
switch(l_pid = fork())
{
case -1:
// error when forking !
ERROR("Forking error");
break;
case 0:
// child process - execute the command
system(x);
exit(EXIT_OTHER);
default:
// parent process continue
nchildren+=1;/* one more child to look after */
break;
-----------------------------------------------------------------------------------------
| **** DISCLAIMER **** http://www.belgacom.be/maildisclaimer |
------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________ Sipp-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/sipp-users
