fix UWIN: don’t close fd #3 (also, int→bool)

This commit is contained in:
tg 2011-02-27 19:29:32 +00:00
parent e0c4ad7fa9
commit 6a941a3c39
2 changed files with 11 additions and 9 deletions

16
main.c
View File

@ -33,7 +33,7 @@
#include <locale.h>
#endif
__RCSID("$MirOS: src/bin/mksh/main.c,v 1.177 2011/02/18 22:26:10 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/main.c,v 1.178 2011/02/27 19:29:31 tg Exp $");
extern char **environ;
@ -957,16 +957,18 @@ tty_init(bool init_ttystate, bool need_tty)
close(tty_fd);
tty_fd = -1;
}
tty_devtty = 1;
tty_devtty = true;
#ifdef _UWIN
/* XXX imake style */
if (isatty(3))
/*XXX imake style */
if (isatty(3)) {
/* fd 3 on UWIN _is_ /dev/tty (or our controlling tty) */
tfd = 3;
else
do_close = false;
} else
#endif
if ((tfd = open("/dev/tty", O_RDWR, 0)) < 0) {
tty_devtty = 0;
if ((tfd = open("/dev/tty", O_RDWR, 0)) < 0) {
tty_devtty = false;
if (need_tty)
warningf(false, "%s: %s %s: %s",
"No controlling tty", "open", "/dev/tty",

4
sh.h
View File

@ -154,7 +154,7 @@
#endif
#ifdef EXTERN
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.432 2011/02/18 22:26:13 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.433 2011/02/27 19:29:32 tg Exp $");
#endif
#define MKSH_VERSION "R39 2011/02/18"
@ -1795,7 +1795,7 @@ int test_eval(Test_env *, Test_op, const char *, const char *, bool);
int test_parse(Test_env *);
EXTERN int tty_fd I__(-1); /* dup'd tty file descriptor */
EXTERN int tty_devtty; /* true if tty_fd is from /dev/tty */
EXTERN bool tty_devtty; /* true if tty_fd is from /dev/tty */
EXTERN struct termios tty_state; /* saved tty state */
extern void tty_init(bool, bool);