Set stdin to text mode, and stdout/stderr to binary mode if not a console

This commit is contained in:
KO Myung-Hun 2015-05-16 15:27:18 +09:00
parent 8168ee626f
commit 29161973e3

6
os2.c
View File

@ -167,6 +167,12 @@ void os2_init(int *argcp, const char ***argvp)
response(argcp, argvp);
env_slashify();
setmode(STDIN_FILENO, O_TEXT);
if (!isatty(STDOUT_FILENO))
setmode(STDOUT_FILENO, O_BINARY);
if (!isatty(STDERR_FILENO))
setmode(STDERR_FILENO, O_BINARY);
}
/* Remove trailing dots. */