[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Bash cannot kill itself?
From: |
Chris F.A. Johnson |
Subject: |
Re: Bash cannot kill itself? |
Date: |
Wed, 30 Jun 2010 01:08:01 -0400 (EDT) |
User-agent: |
Alpine 2.00 (LMD 1167 2008-08-23) |
On Wed, 30 Jun 2010, Clark J. Wang wrote:
> On Wed, Jun 30, 2010 at 12:38 PM, Chris F.A. Johnson
> <chris@cfajohnson.com>wrote:
>
> > On Wed, 30 Jun 2010, Clark J. Wang wrote:
> >
> > > I have a bash script like this:
> > >
> > > #!/bin/bash
> > >
> > > trap 'echo killed by SIGALRM; exit 1' ALRM
> > >
> > > function wait_kill()
> > > {
> > > sleep 5
> > > kill -ALRM $$
> > > }
> > >
> > > wait_kill &
> > >
> > > sleep 3600
> > >
> > > ### END OF THE SCRIPT ###
> > >
> > > It does not work as I expected. The running script was not terminated
> > after
> > > 5 seconds. So what's wrong here?
> >
> > $$ refers to the subshell.
>
>
> There's no subshell here, I think.
The background process invoked by &.
> > Try:
> >
> > trap 'echo killed by SIGALRM; exit 1' ALRM
> >
> > function wait_kill()
> > {
> > sleep 5
> > kill -ALRM $pid
> > }
> >
> > pid=$$
> > wait_kill &
> >
> > sleep 3600
> >
> > --
> > Chris F.A. Johnson, <http://cfajohnson.com>
> > Author:
> > Pro Bash Programming: Scripting the GNU/Linux Shell (2009, Apress)
> > Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
> >
>
--
Chris F.A. Johnson, <http://cfajohnson.com>
Author:
Pro Bash Programming: Scripting the GNU/Linux Shell (2009, Apress)
Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
- Bash cannot kill itself?, Clark J. Wang, 2010/06/30
- Re: Bash cannot kill itself?, Chris F.A. Johnson, 2010/06/30
- Re: Bash cannot kill itself?, Clark J. Wang, 2010/06/30
- Re: Bash cannot kill itself?,
Chris F.A. Johnson <=
- Re: Bash cannot kill itself?, Jan Schampera, 2010/06/30
- Re: Bash cannot kill itself?, Clark J. Wang, 2010/06/30
- Re: Bash cannot kill itself?, Jan Schampera, 2010/06/30
- Re: Bash cannot kill itself?, Clark J. Wang, 2010/06/30
- Re: Bash cannot kill itself?, Chris F.A. Johnson, 2010/06/30
- Re: Bash cannot kill itself?, Pierre Gaston, 2010/06/30
- Re: Bash cannot kill itself?, Pierre Gaston, 2010/06/30
- Re: Bash cannot kill itself?, Clark J. Wang, 2010/06/30
Re: Bash cannot kill itself?, Andreas Schwab, 2010/06/30