by andreyv · 4y ago · 0 comments
The process ID of the last executed background command in Bash is available as $!.
cat <(sort nonexistent)
wait $! || echo fail
gives sort: cannot read: nonexistent: No such file or directory
failAfter a quick search it doesn't seem like this is an option for anything but the last executed background process. So if you have the typical `diff <(left) <(right)`, there is no easy way to get the pid of `<(left)`.
I suppose you could output the pid to a file, and use it from there, though I haven't tested if that would work.