cloexec: preserve text vs. binary across dup_cloexec
On mingw, dup_cloexec mistakenly converted a text fd into a
binary fd. Cygwin copied the source mode. Most other platforms
don't distinguish between modes.
* lib/cloexec.c (dup_cloexec) [W32]: Query and use translation
mode.
* modules/dup2-tests (Depends-on): Add binary-io.
* modules/cloexec-tests (Depends-on): Likewise.
* tests/test-dup2.c (setmode, is_mode): New helpers.
(main): Add tests that translation mode is preserved.
* tests/test-cloexec.c (setmode, is_mode, main): Likewise.
Reported by Bruno Haible.
Signed-off-by: Eric Blake <ebb9@byu.net>