*BSD News Article 46125


Return to BSD News archive

Path: sserve!newshost.anu.edu.au!harbinger.cc.monash.edu.au!simtel!zombie.ncsc.mil!news.mathworks.com!gatech!howland.reston.ans.net!Germany.EU.net!zib-berlin.de!news.tu-chemnitz.de!irz401!uriah.heep!not-for-mail
From: j@uriah.heep.sax.de (J Wunsch)
Newsgroups: comp.unix.bsd.freebsd.misc
Subject: Re: Auto-killing slattach?
Date: 24 Jun 1995 12:34:26 +0200
Organization: Private FreeBSD site, Dresden.
Lines: 68
Message-ID: <3sgpni$6nm@uriah.heep.sax.de>
References: <kientzleDAJ8zB.FHo@netcom.com> <3sfa4t$n32@solaris.cc.vt.edu> <3sfbvf$q3i@agate.berkeley.edu> <3sfdu1$os4@Mars.mcs.com>
NNTP-Posting-Host: uriah.heep.sax.de
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit

Christopher Hilton <chilton@MCS.COM> wrote:

> The
>latest one stores the pid of the slattach process for each invocation
>in /var/run. If you are trying to kill the slattach program this
>comes in handy as you can do something like:
>
>     kill `cat /var/run/slattach.cua00`

So somebody is actually using this feature now. :-) I've stumpled
across this when hacking my Perl dialing/shutdown scripts for my own
SLIP link.  I thought it has been rather a serious inconsistency that
the slattach didn't drop PID files like many other daemons do,
especially given the fact that it's forking itself half a dozen times,
so there' no logic at all on how to obtain the PID otherwise.  (And
yes, i do hate those ``killall'' approaches.)


[slattach not providing a facility to shut down the interface on exit]

>This is a similar mechanism to the -u unit command. The only reason
>that I hadn't said something before is because I doubted that many
>people are using more than one slip unit at a time.

Hmm, additional arguments will confuse those (like me) who used to
perform some script-tweaking of their own.  But how about running the
`-u' command (config_cmd) again on exit, this time with a new slunit
number of -1?  (It's already run with an `old' unit number of -1 at
startup.)

The text is suggesting that it's already doing something like this,
but apparently it got lost on the way:


/* Run config_cmd if specified before exiting. */
       ^^^^^^^^^^
void exit_handler(int ret)
{
        if(exiting) return;
        exiting = 1;
        /*
         * First close the slip line in case exit_cmd wants it (like to hang
         * up a modem or something).
         */
        if (fd != -1)
                close(fd);

        /* Remove the PID file */
        (void)unlink(pidfilename);

        /* invoke a shell for exit_cmd. */
        if (exit_cmd) {
            ^^^^^^^^
                syslog(LOG_NOTICE,"exiting after running %s", exit_cmd);
                system(exit_cmd);
        }
        exit(ret);
}


Since you happen to have more than one link and can actually also test
it, please come up with a patch.  Send it by send-pr, or send it
directly to me, and i'm happy to commit it to the source.
-- 
cheers, J"org

joerg_wunsch@uriah.heep.sax.de -- http://www.sax.de/~joerg/
Never trust an operating system you don't have sources for. ;-)