Subject: Another zombie killer

From: [email-masked]
Date: Mon, 18 Aug 1997 13:32:10 -0400 (EDT)

I had a similar script that I figured I might as well post. I have
the script mailing me the results of the kill sessions.

Doug

#! /usr/local/bin/perl

# Looks for wuftp processes that are older then 24 hours and kill the
# process and sends mail to dougc

open(PS,"ps -ef | grep '/opt/wuftpd/etc/wuftpd '|") || die "Can't open ps";
open(MAILFILE,">/tmp/mailfile") || die "Can't open mailfile";

while(<PS>) {
        chop;
        s/^\s+//;
        ($id,$pid,$ppid,$dum,$stime) = split(/\s+/,$_,5);
        if ( $stime =~ /^[JFMASOND].*/){
                kill 9, $pid;
                print MAILFILE "killing $pid $stime\n";
        }
        else {
                print MAILFILE "skip $stime\n";
        }
}
close(PS);
close(MAILFILE);
system("/usr/sbin/mailx -s 'Killed processes' [YOUR MAIL ID HERE] < /tmp/mailfile");
unlink("/tmp/mailfile");

-- 
Doug Courtney
[email-masked]
(732)576-5572

---

From: Jon Lewis <[email-masked]>
Date: Mon, 18 Aug 1997 14:04:31 -0400 (EDT)

> the script mailing me the results of the kill sessions.

Wouldn't it be better to fix ftpd?  Since I added some alarm() calls and
the -z switch about a month ago, I've not seen a single ftpd hang.

------------------------------------------------------------------
 Jon Lewis <[email-masked]>  |  Unsolicited commercial e-mail will
 Network Administrator       |  be proof-read for $199/message.
 Florida Digital Turnpike    |  
______http://inorganic5.fdt.net/~jlewis/pgp for PGP public key____

---

From: Michael Brennen <[email-masked]>
Date: Mon, 18 Aug 1997 13:25:20 -0500 (CDT)

Did these make it into B14?  If not could you post a patch?  TIA...

   -- Michael

---

From: Jon Lewis <[email-masked]>
Date: Mon, 18 Aug 1997 14:46:50 -0400 (EDT)

> Did these make it into B14?  If not could you post a patch?  TIA...

No.  I'm using a very much hacked up version of beta-11.  I'll look at
upgrading to beta-14 and adapting my patch to it, and then post one
relative to 14.

---

From: Ben Mehlman <[email-masked]>
Date: Mon, 18 Aug 1997 15:41:22 -0400 (EDT)

> the -z switch about a month ago, I've not seen a single ftpd hang.

Yes, I would have done that also..  but I'm running a hacked 2.4 and don't
want to mess with it more than necessary.. looking toward the day I upgrade.

BUt if this is going to be added to the distribution, I might take this
moment to express my preference for select() before read() from the data
connection.  This eliminates more signal nightmares and puts the fix where
it should have been in the first place- right in the code that's causing the
problem.  If I were to write ftpd from scratch today, well, I'd use threads
;)  But barring that, I'd use select() to watch over the two connections at
once, and eliminate the need for alarm() or OOB data, and the associated
signal handlers.

-Ben

----------------------------------------------------------------------------
Ben Mehlman             The reasonable man adapts himself to the world; the 
Prodigy Services Corp   unreasonable one persists in trying to adapt the
[email-masked]   world to himself.  Therefore all progress depends on
                        the unreasonable man. -George Bernard Shaw