Write in binary mode through pipes
On kLIBC, a child inherits a translation mode of stdio/stdout/stderr of a parent. So if setting stdio handles of a parent to text mode, a child reads CR+LF as LF and write LF to CR+LF. Especially, LF to CR+LF conversion causes many troubles in UNIX programs. Instead, if a child inherts a child inherit a current translation mode, where stdin is text mode, stdout and stderr are binary mode, a child would write LF as is. This is the way for OS/2 to survive in UNIX jungle. For example, 'make check' of libiconv fails due to mismatch of CR+LF and LF.
This commit is contained in:
parent
2b9eed78a0
commit
18ff277047
16
os2.c
16
os2.c
@ -396,9 +396,6 @@ int execve(const char *name, char * const *argv, char * const *envp)
|
||||
char sign[2];
|
||||
char *rsp_argv[3];
|
||||
char *rsp_name_arg;
|
||||
int saved_stdin_mode;
|
||||
int saved_stdout_mode;
|
||||
int saved_stderr_mode;
|
||||
int pid;
|
||||
int status;
|
||||
int fd;
|
||||
@ -442,14 +439,6 @@ int execve(const char *name, char * const *argv, char * const *envp)
|
||||
if (errno == ENOEXEC)
|
||||
return -1;
|
||||
|
||||
/*
|
||||
* On kLIBC, a child inherits a translation mode of stdin/stdout/stderr
|
||||
* of a parent. Set stdin/stdout/stderr to a text mode, which is default.
|
||||
*/
|
||||
saved_stdin_mode = setmode(fileno(stdin), O_TEXT);
|
||||
saved_stdout_mode = setmode(fileno(stdout), O_TEXT);
|
||||
saved_stderr_mode = setmode(fileno(stderr), O_TEXT);
|
||||
|
||||
rsp_name_arg = make_response_file(argv);
|
||||
|
||||
if (rsp_name_arg) {
|
||||
@ -465,11 +454,6 @@ int execve(const char *name, char * const *argv, char * const *envp)
|
||||
if (rsp_name_arg)
|
||||
afree(rsp_name_arg, ATEMP);
|
||||
|
||||
/* Restore a translation mode of stdin/stdout/stderr. */
|
||||
setmode(fileno(stdin), saved_stdin_mode);
|
||||
setmode(fileno(stdout), saved_stdout_mode);
|
||||
setmode(fileno(stderr), saved_stderr_mode);
|
||||
|
||||
if (pid == -1) {
|
||||
cleanup_temps();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user