[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Possible bash bug?

From: Greg Wooledge
Subject: Re: Possible bash bug?
Date: Wed, 22 Jun 2016 09:45:11 -0400
User-agent: Mutt/

On Wed, Jun 22, 2016 at 10:34:59AM +0100, John Lawlor wrote:
> If I do the following:
> bash -c "ping > $HOME/console.log"  &

> Now if I kill bash:
> Bash is killed but not the child ping process. I was expecting that to be 
> killed also.

Not a bug.  If you want a signal (e.g. SIGTERM) to be caught by bash
and propagated to bash's children, you need to catch it and send it
to your children.  This also means you have to run your children as
background processes and capture their PIDs.  Otherwise, if the child is
a foreground process, bash will not receive the signal until the child
exits on its own.

For example:

unset pid
trap '[[ $pid ]] && kill $pid' EXIT
ping >~/console.log &

reply via email to

[Prev in Thread] Current Thread [Next in Thread]