@sunfish Wouldn't the problem of dup-then-close being ignored due to reference counting also apply on the file descriptors passed by the shell? (Which effectively does open/fd-pass/close for redirections)
Also for me calling close on files explicitly opened makes sense, while calling close on passed fds feels weird although exit(), implied for returns from main, closes all open streams. (cf. ISO C)