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 sleep 5 When I run the script with the parameter "b" instead, I get two lines of output: 1000 12117 0.0 0.0 9728 828 pts/1 S+ 01:39 0:00 sleep 5 ./foo.sh: line 11: 12116 Terminated { sleep 5; } 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"? What's even more puzzling to me is that removing the "wait %1" call makes the problem disappear. That is, without the wait call the sleep 5 job properly terminates due to the kill, no matter if it was in curly braces or not. How can the wait call affect a job it's not supposed to wait for? Christoph (I use "GNU bash, version 4.1.5(1)-release (x86_64-pc-linux-gnu)" on Ubuntu 10.04.)