Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 20 Jan 2005 01:33:03 +0900
From:      Rob <spamrefuse@yahoo.com>
To:        Rob <spamrefuse@yahoo.com>, freebsd-stable@freebsd.org
Subject:   Re: User's cron job creates zombie process on 5.3
Message-ID:  <41EE8BBF.1010408@yahoo.com>

next in thread | raw e-mail | index | archive | help
Raymond Wiker wrote:
> 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.

No, makes no difference.

Peculiar of the problem is: I use this construct to keep a ssh-tunnel alive.
What else is better, than having a cron-script check whether the tunnel is
still active, and if not, re-establish the ssh-tunnel.
Strange, that such an obvious contruct ends up with a zombie process.

Another interesting detail: as soon as I kill the tunnel, created by the
cron-script, then the zombie process also disappears. Does that give a clue?

Any more suggestions how to tackle this?

Thsnks,
Rob.






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