[Raw Msg Headers][Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

router droping zombies - solved



Hi!
Few months ago I was asking for help because the router under Solaris
was droping a lot of zombies.
After some debugging/tracing/testing I have discovered the reason.
Inside libsh/execute.c there is a pair of defines used for spawning
grand-child. In that construction an intermediate process is spawned
just to start the grand-child and die. This way the grand-child becomes
an orphan and is adopted by init. The problem comes from the fact that
nobody reads the status of the intermediate process so it becomes a zombie
and stays in this state until his parent dies. The parent never dies,
(except for restarts) so the process stays forever in the process table.

The solution adds just one wait() to read exit status of the intermediate process
and thus remove it from the process table.
Here is the patch.

*** libsh/execute.c.ORG	Mon Aug 28 10:07:06 1995
--- libsh/execute.c	Tue Mar 19 12:46:50 1996
***************
*** 80,88 ****
  #define	ENDGRANDCHILD(P)			_exit(0);\
  					} else if (P < 0)\
  						perror("fork");\
  					_exit(0);\
! 				} else if (P < 0)
  
  #ifdef	USE_UNIONWAIT
  typedef union wait status_t;
  #else	/* !USE_UNIONWAIT */
--- 80,91 ----
  #define	ENDGRANDCHILD(P)			_exit(0);\
  					} else if (P < 0)\
  						perror("fork");\
  					_exit(0);\
! 				} else if (P > 0) /* JS+ */ \
! 					wait(&sTaTus); /* JS+ */ \
! 				 else if (P < 0)
! int sTaTus;		/* JS+ */
  
  #ifdef	USE_UNIONWAIT
  typedef union wait status_t;
  #else	/* !USE_UNIONWAIT */

I hope that the author will examine this code (check for protability)
and use it in future releases after proper modifications.
The funny spelling of sTaTus was used to avoid name conflicts without
carefully examining the code (I am a bit lazy ;-)
Cheers!
	Jerzy

------------------------------------------------------------------------
Jerzy Sobczyk              ____________ ___     Institute of Control and
J.Sobczyk@ia.pw.edu.pl    /  /     |  |/  _\    Computation Engineering, 
                         /  /  /|  |  |  (____         Warsaw University 
tel.+48 22 660 7297     /  /  _>|  |  |\____  \            of Technology
fax.+48 22 253719      /__/__/__|__|__|_____)  \       Nowowiejska 15/19
tlx. 813 307 pw pl    /________________________/   00-665 Warsaw, POLAND 
------------------------------------------------------------------------