$ bash -c '{ sleep 15; } & pstree -p $!; kill $!; echo $?' bash(6955)───sleep(6959) 0 $ pkill -e sleep sleep killed (pid 6959)
As seen above, kill $! doesn't kill `sleep` if it's enclosed in curly braces. Dropping curly braces, or execing sleep (e.g `{ exec sleep 15; }`) fixes this problem, but I didn't understand why. I could reproduce this on 3 different machines with 3 three different bash versions; so this is either a bug, or I'm missing something really simple. The other reason I think this might be a bug is that this isn't reproducible on other shells like dash, mksh, etc. This time in order not to waste anyone's time I checked if there is something about this in devel branch's Changelog file but couldn't find anything relevant. Regards -- Oğuz