On Tue, Feb 19, 2002 at 05:42:35PM +0100, Viktor Rosenfeld wrote:
> Hi,
> 
> I have the following bash question.  I've written a script that makes
> sure that I'm online (ISDN dial-on-demand) and then gets mail with
> fetchmail.  He're the code that makes sure I'm connected and prints dots
> while doing so:
> 
>       # Make sure we're online
>       echo -n "Connecting to the internet .."
>       /bin/bash -c 'while true; do echo -n "."; sleep 1s; done' &
>       DOTLOOP=$!
>       ping -c 1 www.web.de > /dev/null
>       kill -9 $DOTLOOP 
>       echo " done."
> 
> This works fine, but after the fetchmail command runs (not shown there)
> I get the following message:
>       
>       /home/viktor/bin/getmail: line 16:  3869 Killed
>       /bin/bash -c 'while true; do echo -n "."; sleep 1s; done'
> 
> This, of course, is not surprising, it's normal bash behavior.
> Unfortunately, I don't like it and would like to suppress it.  Any way
> to achieve this?

With "kill -9", there is no way the shell can catch it. It's a bit of a
shotgun approach to getting rid of the process (man 7 signal).

However, if you were to settle for the normal kill (= SIGTERM), then you
should be OK:
    #!/bin/sh

    echo -n "Doing something.."
    (while true; do echo -n "."; sleep 1; done) &
    DOTLOOP=$!
    ping -c 1 www.web.de > /dev/null
    kill $DOTLOOP 
    echo " done."

HTH
-- 
Karl E. Jørgensen
[EMAIL PROTECTED]
www.karl.jorgensen.com
==== Today's fortune:
The University of California Statistics Department; where mean is normal,
and deviation standard.

Attachment: pgpQltjniiOug.pgp
Description: PGP signature

Reply via email to