give tty_init() another argument for silent initialisation
This commit is contained in:
parent
dc79b9b118
commit
2fb7225499
6
jobs.c
6
jobs.c
@ -2,7 +2,7 @@
|
||||
|
||||
#include "sh.h"
|
||||
|
||||
__RCSID("$MirOS: src/bin/mksh/jobs.c,v 1.42 2008/12/13 17:02:15 tg Exp $");
|
||||
__RCSID("$MirOS: src/bin/mksh/jobs.c,v 1.43 2008/12/29 20:47:15 tg Exp $");
|
||||
|
||||
/* Order important! */
|
||||
#define PRUNNING 0
|
||||
@ -155,7 +155,7 @@ j_init(int mflagset)
|
||||
if (Flag(FMONITOR))
|
||||
j_change();
|
||||
else if (Flag(FTALKING))
|
||||
tty_init(true);
|
||||
tty_init(true, true);
|
||||
}
|
||||
|
||||
/* job cleanup before shell exit */
|
||||
@ -217,7 +217,7 @@ j_change(void)
|
||||
|
||||
/* Don't call tcgetattr() 'til we own the tty process group */
|
||||
if (use_tty)
|
||||
tty_init(false);
|
||||
tty_init(false, true);
|
||||
|
||||
/* no controlling tty, no SIGT* */
|
||||
if ((ttypgrp_ok = use_tty && tty_fd >= 0 && tty_devtty)) {
|
||||
|
29
main.c
29
main.c
@ -13,7 +13,7 @@
|
||||
#include <locale.h>
|
||||
#endif
|
||||
|
||||
__RCSID("$MirOS: src/bin/mksh/main.c,v 1.116 2008/12/13 17:02:15 tg Exp $");
|
||||
__RCSID("$MirOS: src/bin/mksh/main.c,v 1.117 2008/12/29 20:47:15 tg Exp $");
|
||||
|
||||
extern char **environ;
|
||||
|
||||
@ -735,9 +735,9 @@ remove_temps(struct temp *tp)
|
||||
* foreground job completion and for setting up tty process group.
|
||||
*/
|
||||
void
|
||||
tty_init(int init_ttystate)
|
||||
tty_init(bool init_ttystate, bool need_tty)
|
||||
{
|
||||
int do_close = 1;
|
||||
bool do_close = true;
|
||||
int tfd;
|
||||
|
||||
if (tty_fd >= 0) {
|
||||
@ -753,26 +753,33 @@ tty_init(int init_ttystate)
|
||||
#endif
|
||||
if ((tfd = open("/dev/tty", O_RDWR, 0)) < 0) {
|
||||
tty_devtty = 0;
|
||||
warningf(false, "No controlling tty (open /dev/tty: %s)",
|
||||
strerror(errno));
|
||||
if (need_tty)
|
||||
warningf(false,
|
||||
"No controlling tty (open /dev/tty: %s)",
|
||||
strerror(errno));
|
||||
}
|
||||
if (tfd < 0) {
|
||||
do_close = 0;
|
||||
do_close = false;
|
||||
if (isatty(0))
|
||||
tfd = 0;
|
||||
else if (isatty(2))
|
||||
tfd = 2;
|
||||
else {
|
||||
warningf(false, "Can't find tty file descriptor");
|
||||
if (need_tty)
|
||||
warningf(false,
|
||||
"Can't find tty file descriptor");
|
||||
return;
|
||||
}
|
||||
}
|
||||
if ((tty_fd = fcntl(tfd, F_DUPFD, FDBASE)) < 0) {
|
||||
warningf(false, "j_ttyinit: dup of tty fd failed: %s",
|
||||
strerror(errno));
|
||||
if (need_tty)
|
||||
warningf(false, "j_ttyinit: dup of tty fd failed: %s",
|
||||
strerror(errno));
|
||||
} else if (fcntl(tty_fd, F_SETFD, FD_CLOEXEC) < 0) {
|
||||
warningf(false, "j_ttyinit: can't set close-on-exec flag: %s",
|
||||
strerror(errno));
|
||||
if (need_tty)
|
||||
warningf(false,
|
||||
"j_ttyinit: can't set close-on-exec flag: %s",
|
||||
strerror(errno));
|
||||
close(tty_fd);
|
||||
tty_fd = -1;
|
||||
} else if (init_ttystate)
|
||||
|
4
sh.h
4
sh.h
@ -103,7 +103,7 @@
|
||||
#define __SCCSID(x) __IDSTRING(sccsid,x)
|
||||
|
||||
#ifdef EXTERN
|
||||
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.268 2008/12/17 19:39:23 tg Exp $");
|
||||
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.269 2008/12/29 20:47:16 tg Exp $");
|
||||
#endif
|
||||
#define MKSH_VERSION "R36 2008/12/17"
|
||||
|
||||
@ -1600,7 +1600,7 @@ EXTERN int tty_fd I__(-1); /* dup'd tty file descriptor */
|
||||
EXTERN int tty_devtty; /* true if tty_fd is from /dev/tty */
|
||||
EXTERN struct termios tty_state; /* saved tty state */
|
||||
|
||||
extern void tty_init(int);
|
||||
extern void tty_init(bool, bool);
|
||||
extern void tty_close(void);
|
||||
|
||||
/* be sure not to interfere with anyone else's idea about EXTERN */
|
||||
|
Loading…
Reference in New Issue
Block a user