The code in the helper identifies which file is being opened based on counting open calls. This works fine for the initial stdout/stderr redirects set up by the helper. However, if the executed program attempts to use /dev/std{out,err}, a new file handle is opened, which the code doesn't handle. Some better mechanism is required to e.g. allow this in a shell script: