Set stdin to text mode before executing child processes
Normal OS/2 programs expect that standard IOs, especially stdin, are opened in text mode at the startup. By the way, on OS/2 kLIBC child processes inherit a translation mode of a parent process. As a result, if stdin is set to binary mode in a parent process, stdin of child processes is opened in binary mode as well at the startup. In this case, some programs such as sed suffer from CR. This is the regression fix of commit 20dbf6. From: KO Myung-Hun <komh@chollian.net>
This commit is contained in:
parent
0faaab7bbc
commit
d93bd77f28
16
os2.c
16
os2.c
|
@ -31,7 +31,7 @@
|
|||
#include <unistd.h>
|
||||
#include <process.h>
|
||||
|
||||
__RCSID("$MirOS: src/bin/mksh/os2.c,v 1.6 2017/10/13 23:34:49 tg Exp $");
|
||||
__RCSID("$MirOS: src/bin/mksh/os2.c,v 1.7 2017/12/22 16:37:14 tg Exp $");
|
||||
|
||||
static char *remove_trailing_dots(char *);
|
||||
static int access_stat_ex(int (*)(), const char *, void *);
|
||||
|
@ -390,6 +390,7 @@ execve(const char *name, char * const *argv, char * const *envp)
|
|||
int status;
|
||||
int fd;
|
||||
int rc;
|
||||
int saved_mode;
|
||||
|
||||
/*
|
||||
* #! /bin/sh : append .exe
|
||||
|
@ -439,8 +440,21 @@ execve(const char *name, char * const *argv, char * const *envp)
|
|||
argv = rsp_argv;
|
||||
}
|
||||
|
||||
/*
|
||||
* Normal OS/2 programs expect that standard IOs, especially stdin,
|
||||
* are opened in text mode at the startup. By the way, on OS/2 kLIBC
|
||||
* child processes inherit a translation mode of a parent process.
|
||||
* As a result, if stdin is set to binary mode in a parent process,
|
||||
* stdin of child processes is opened in binary mode as well at the
|
||||
* startup. In this case, some programs such as sed suffer from CR.
|
||||
*/
|
||||
saved_mode = setmode(STDIN_FILENO, O_TEXT);
|
||||
|
||||
pid = spawnve(P_NOWAIT, exec_name, argv, envp);
|
||||
|
||||
/* restore translation mode of stdin */
|
||||
setmode(STDIN_FILENO, saved_mode);
|
||||
|
||||
afree(rsp_name_arg, ATEMP);
|
||||
|
||||
if (pid == -1) {
|
||||
|
|
Loading…
Reference in New Issue