Created attachment 1609 [details]
pfiles on running sftp-server shows:
3: S_IFIFO mode:0000 dev:329,0 ino:91352 uid:0 gid:0 size:0
4: S_IFIFO mode:0000 dev:329,0 ino:91353 uid:0 gid:0 size:0
those descriptors are created by 2 dup() calls on STD(IN|OUT)_FILENO. However, there is no need for that and sftp-server can work directly with 0 and 1. I see that this code came with the 1st sftp-server implementation in version 2.3.0p1 and hasn't change since then. Even the Cygwin code that follows those dup()'s and which looks like it might need those came long after that. After the attached patch was applied, the full output of pfiles follows and there is no regression.
0: S_IFIFO mode:0000 dev:340,0 ino:1570 uid:0 gid:0 size:0
1: S_IFIFO mode:0000 dev:340,0 ino:1571 uid:0 gid:0 size:0
2: S_IFIFO mode:0000 dev:340,0 ino:1572 uid:0 gid:0 size:0
the "make tests" passed all tests.
committed - will be in openssh-5.4. Thanks
With the release of 5.4p1, this bug is now considered closed.