Subject: Re: pppd & tail show PID after ppp-down
To: None <netbsd-help@netbsd.org>
From: James K. Lowden <jklowden@schemamania.org>
List: netbsd-help
Date: 10/16/2001 02:20:13
On Mon, Oct 15, 2001 at 11:58:50PM -0400, Gan Uesli Starling wrote:
> Your's at least can go straight into the script. Mine, being csh (I couldn't 
> puzzle out the sh) has to be called as a separate script.
> 
> And I'm thinking that the complex kill of PPP is at least targeted to the 
> specific TTY, where is our kills of tail do slay every tail that they doeth 
> find, no? Could I, like, modify ppp-up to set a variable on which tail it 
> started, and have ppp-down just yank down that one? Somebody might be running 
> a second tail and not want it cut clean of without at least a by-your-leave.

Hi Gan, 

Well, ps -T limits the list to your tty, with the advantage that it
won't go off killing tails willy-nilly, but the disadvantage that you
have to run ppp-down in the same tty as ppp-up for it to work.  And I
am specifically looking for a tail -f of /var/log/messages, but, yeah,
it's less than elegant.  

You surely can determine your own pid, but can I first offer a shell
suggestion?  I know there's more than one opinion on this question
generally and probably two religions, too, so stand well clear.  I
think csh is the [ahem] wrong place to start.  When Bill Joy wrote
it, many of the features were new (and needed).  AIUI, it was the
first "interactive" shell.  Since then, many of the ideas introduced
by the C shell were copied and improved on by others.  

Tom Christiansen wrote a thoughtful polemic about it.  

	http://www.perl.com/pub/a/language/versus/csh.html

As a practical matter, I have the (dataless) impression that you
won't find as many people who are intimately familiar with csh as with
sh.  

The Bourne shell (sh) is the standard for BSDs.  Although I imagine
it's heresy to tout a Gnu program on a BSD forum, I have to say I
wouldn't be without bash, which is [ducking] basically sh++.  I
normally run my scripts with #!/bin/sh, though, unless I'm making use
of some special bash feature.  I think you'll find the bash
documentation a little more approachable than the standared sh docs. 
At least, I did.  

Just one man's opinion, of course.  I'm sure if I'm off base we'll
learn about it soon enough.  

I didn't know how to get the shell's pid in bash, either.  I pointed
my browser to the bash html docs, clicked on the Variables section,
scanned it for "PID", and found:

	$PPID	the pid of the parent process, the xterm.
	$$		the pid of the shell process (what you want)
	
It's simple to echo the $$ variable to a file (say,
/var/run/ppp0.ppp-up.pid).  Then ppp-down can read that file, kill
the process, and delete the file.  That's one way to skin the cat.  

Regards, 

--jkl