On 6/4/19 4:34 PM, mwnx wrote: > Thanks for the explanation. In view of the change you describe, > there is another behaviour that I think might qualify as a bug. I'll > give you my actual use case first. > > I simply want to make sure all processes running inside a given > subshell are killed on exit. To that means, I set up the following > trap in the shell (and potentially, its subshells and so on): > > trap 'kill $(jobs -p) &>/dev/null || true; wait' EXIT > > This was working fine in bash 4.x, despite `jobs -p` not returning > the process ID of process substitutions. But now that `wait` (with > no arguments) waits for process substitutions in addition to > "ordinary" foreground and background processes, the situation is > asymmetric, leading to my subshells freezing when killed while a > process substitution is running.
Not quite. `wait' without arguments waits for the last process substitution, and the pid of that process is available in $! for the cases you care about. If you are sure that your script hasn't started any asynchronous processes since the last process substitution, you can use $! directly. Otherwise, you can capture it into a variable and use it in the `kill' command. You should also ensure that you're using bash-5.0 with patch 4 applied, since that is relevant to this issue. -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ``Ars longa, vita brevis'' - Hippocrates Chet Ramey, UTech, CWRU c...@case.edu http://tiswww.cwru.edu/~chet/