On Wed, Apr 06, 2011 at 03:32:14PM -0700, Walt Pawley wrote:
> My IPv6 tunnel has a tendency to vanish from time to time. So I
> thought I might write a script to check that and attempt
> reconstituting it if needed. After some considerable messing
> about, I really thought this ...
> 
> #!/bin/sh
> if ifconfig en1|grep -q "inet6 2001" ; then exit;
> else
>         if ps -ax | grep gw6c | grep -qv grep;
>         then ps -ax | grep gw6c | grep -v grep | ( read x y; kill "$x" )
>         fi
>         cd /usr/local/gw6c/bin
>         ./gw6c
> fi
> 
> ... should work. But I was wrong, as usual. In the case where
> the tunnel has vanished, the gw6c program often does not quit
> right away, and it is usually soaking up a lot of processor in
> that mode. Thus it was necessary to test for gw6c running and
> terminate it if it was. Curiously, even when it was not
> running. the test above would fail in the script. On the
> command line, it seemed, as near as I could tell, to work just
> fine.
> 
> Grasping at straws, I decided to try the following:
> 
> #!/bin/sh
> if ifconfig en1|grep -q "inet6 2001" ; then exit;
> else
>         if $( ps -ax | grep gw6c | grep -qv grep );
>         then ps -ax | grep gw6c | grep -v grep | ( read x y; kill "$x" )
>         fi
>         cd /usr/local/gw6c/bin
>         ./gw6c
> fi
> 
> It worked just fine. I'd like to know why this disparity. It's
> probably something mind bogglingly simple but my researches
> have yet to unboogle me. Can you?

Not the answer you asked for, but... you should really take a look at
pkill(1) instead of that check.


HTH,
Yuri
_______________________________________________
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"

Reply via email to