Re: Strange behavior with job control

2010-07-27 Thread Christoph Dittmann
On 07/27/2010 02:35 PM, Greg Wooledge wrote: > On Tue, Jul 27, 2010 at 01:44:26PM +0200, Christoph Dittmann wrote: >> What I was going for was a script which executes another command with a >> timeout. > > http://mywiki.wooledge.org/BashFAQ/068 The process I want to put under the timeout does not

Re: Strange behavior with job control

2010-07-27 Thread Greg Wooledge
On Tue, Jul 27, 2010 at 01:44:26PM +0200, Christoph Dittmann wrote: > What I was going for was a script which executes another command with a > timeout. http://mywiki.wooledge.org/BashFAQ/068 http://mywiki.wooledge.org/XyProblem

Re: Strange behavior with job control

2010-07-27 Thread Christoph Dittmann
On 07/27/2010 02:05 PM, Eric Blake wrote: > On 07/27/2010 05:44 AM, Christoph Dittmann wrote: >> What I was going for was a script which executes another command with a >> timeout. > > If you can assume the presence of GNU coreutils, use timeout(1). Much > nicer for this particular task. Thanks,

Re: Strange behavior with job control

2010-07-27 Thread Eric Blake
On 07/27/2010 05:44 AM, Christoph Dittmann wrote: > What I was going for was a script which executes another command with a > timeout. If you can assume the presence of GNU coreutils, use timeout(1). Much nicer for this particular task. Otherwise, I did not review your script for accuracy. --

Re: Strange behavior with job control

2010-07-27 Thread Christoph Dittmann
On 07/27/2010 12:05 PM, Andreas Schwab wrote: > If you want to kill the whole background job you need to enable job > control (set -m) and call kill with the job specifier instead (kill %2 > in this case). > >> How can the wait call affect a job it's not supposed to wait for? > > It's a simple ra

Re: Strange behavior with job control

2010-07-27 Thread Andreas Schwab
Christoph Dittmann writes: > Why is "sleep 5" still running in the second case even though the job > received SIGTERM and is known to the job control as "terminated"? Try adding "ps f" before the wait command to see the difference in how bash executes the two cases. In the case without the brac

Strange behavior with job control

2010-07-26 Thread Christoph Dittmann
Hi, consider the following script: #!/bin/bash sleep 0.5 & if [[ $1 = a ]]; then sleep 5 & else { sleep 5; } & fi PID=$! wait %1 kill $PID ps aux | grep '[s]leep 5' exit 0 When I run this script with parameter "a" I get the following output: ./foo.sh: line 11: 12132 Terminated