Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 19 Jan 2005 16:47:10 +0100
From:      Raymond Wiker <Raymond.Wiker@fast.no>
To:        Rob <spamrefuse@yahoo.com>
Cc:        freebsd-stable@freebsd.org
Subject:   Re: User's cron job creates zombie process on 5.3
Message-ID:  <16878.33022.866459.717977@raw.grenland.fast.no>
In-Reply-To: <41EE7C44.2010407@yahoo.com>
References:  <41EE7C44.2010407@yahoo.com>

next in thread | previous in thread | raw e-mail | index | archive | help
Rob writes:
 > Raymond Wiker wrote:
 > > Peter Jeremy writes:
 > >  > On Wed, 2005-Jan-19 09:16:59 +0900, Rob Lahaye wrote:
 > >  > >  tunnel="-L 55110:localhost:110 pop3.univ.net"
 > >  > >  tunnel_up=`pgrep -f -- "${tunnel}"`
 > >  > >  [ "${tunnel_up}" = "" ] && /usr/bin/ssh -N -f ${tunnel}
 > >  > 
 > >  > >It works beautifully, but why does this also generate one zombie process:
 > >  > > USER  PID %CPU %MEM   VSZ  RSS  TT  STAT STARTED      TIME COMMAND
 > >  > > rob   655  0.0  0.0     0    0  ??  Z    Sat02PM   0:00.01 <defunct>
 > >  > 
 > >  > You get a zombie when a process has exited and the parent hasn't issued
 > >  > a wait(2) (or SIG_IGN'd SIGCHLD).  Have a look at what the parent process
 > >  > is and that might give you an idea as to what is going wrong.
 > > 
 > >         Ancient Perl did not collect for children started via the
 > > backtick operator - is this a possible issue for /bin/sh as well? It
 > > should be harmless to call wait just after the use of the backtick
 > > operator above; does that change anything? I.e:
 > > 
 > >         tunnel_up=`pgrep -f -- "${tunnel}"`; wait
 > > 
 > >         To see the parent pid, add "-O ppid" to the arguments to ps;
 > > e.g,
 > > 
 > > ps axww -O ppid
 > 
 > Adding the "wait" here does not help at all.
 > 
 > When I verify the parent process I have this:
 > 
 >    PID  PPID  TT  STAT      TIME COMMAND          USER   %CPU %MEM   VSZ  RSS STARTED
 >    423   417  ??  I      0:00.00 cron: running jo root    0.0  0.2  1360 1148 11:38PM
 >    425   423  ??  Z      0:00.00 <defunct>        lahaye  0.0  0.0     0    0 11:38PM
 > 
 > 
 > So PID 423 "cron: running job (cron)" is the parent of my <defunct> zombie.
 > 
 > After playing with commenting out lines, I found out that the ssh call is the
 > reason for the zombie:  "/usr/bin/ssh -N -f -L 55110:localhost:110 pop3.univ.net"
 > 
 > Then I tried exec  : "exec /usr/bin/ssh -N -f ..."
 > And I also tried & : "/usr/bin/ssh -N -f ... &"
 > Both to no avail.
 > 
 > What else can I try, and why is this ssh command causing a zombie process when
 > called from cron?

        Hmm... Maybe this will work?

        /bin/sh -c "/usr/bin/ssh -n -f ${tunnel} &"

--- the effect of this should (hopefully) be that init becomes the
parent of the zombie process.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?16878.33022.866459.717977>