Hi all,
lately I found that a bash script which uses a named pipe/FIFO for process substitution sometimes leaves
/tmp/sh-np.<nnnnnn>
files behind. This does not happen upon each invocation of the script, so it seems to be a race condition. It does only occur on systems that have the bash v5 RPM installed (5.1.4-2, to be more exact). On systems with the same AIX level (7200-05-04-2220) and bash v4 (4.3.30-1), the script runs without such remnants.
Here's a short example script to reproduce the problem:
#!/bin/bash
read min maj < <(uname -rv)
exec echo $maj $min
The
exec
command is what also matters here. Without that, there's also no such
/tmp/sh-np.<nnnnnn>
file afterwards. Sure enough in the real script this is used differently than in the example above, i.e. it invokes another command (
perl
in this case) that inherits some arguments and replaces the shell. Obviously when that happens, the named pipe/FIFO is not cleaned up correctly.
On a Linux system with bash v5 I don't see this behavior. So it appears to be specific to AIX and the bash v5 RPM for AIX.
BTW, there's another thread where this has already been discussed about a year ago, but there were no suggestions other than deleting these files afterwards. I'd rather see them not being left over, especially when the respective script is run frequently (via cron).
Any thoughts, comments or chances that this could be fixed? Thanks.
Regards,
Markus