dup2: work around mingw and cygwin 1.5 bug