tmp.c_lflag &= ~(ICANON | ECHO);
tmp.c_cc[VMIN] = 1;
tmp.c_cc[VTIME] = 0;
- tcsetattr (0, TCSANOW, &tmp);
+ tcsetattr_stdin_TCSANOW(&tmp);
#endif
if (def == 1)
break;
if (c == 3) {
#ifdef HAVE_TERMIOS_H
- tcsetattr (0, TCSANOW, &termios);
+ tcsetattr_stdin_TCSANOW(&termios);
#endif
if (e2fsck_global_ctx &&
e2fsck_global_ctx->flags & E2F_FLAG_SETJMP_OK) {
else
puts ("no\n");
#ifdef HAVE_TERMIOS_H
- tcsetattr (0, TCSANOW, &termios);
+ tcsetattr_stdin_TCSANOW(&termios);
#endif
return def;
}
term_vi.c_cc[VMIN] = 1;
term_vi.c_cc[VTIME] = 0;
erase_char = term_vi.c_cc[VERASE];
- tcsetattr(0, TCSANOW, &term_vi);
+ tcsetattr_stdin_TCSANOW(&term_vi);
}
static void cookmode(void)
{
fflush(stdout);
- tcsetattr(0, TCSANOW, &term_orig);
+ tcsetattr_stdin_TCSANOW(&term_orig);
}
//----- Come here when we get a window resize signal ---------
/* NB: typically you want to pass fd 0, not 1. Think 'applet | grep something' */
int get_terminal_width_height(int fd, unsigned *width, unsigned *height) FAST_FUNC;
+int tcsetattr_stdin_TCSANOW(const struct termios *tp) FAST_FUNC;
+
/* NB: "unsigned request" is crucial! "int request" will break some arches! */
int ioctl_or_perror(int fd, unsigned request, void *argp, const char *fmt,...) __attribute__ ((format (printf, 4, 5))) FAST_FUNC;
int ioctl_or_perror_and_die(int fd, unsigned request, void *argp, const char *fmt,...) __attribute__ ((format (printf, 4, 5))) FAST_FUNC;
tty.c_lflag =
ISIG | ICANON | ECHO | ECHOE | ECHOK | ECHOCTL | ECHOKE | IEXTEN;
- tcsetattr(STDIN_FILENO, TCSANOW, &tty);
+ tcsetattr_stdin_TCSANOW(&tty);
}
/* Open the new terminal device.
tio = oldtio;
tio.c_iflag &= ~(IUCLC|IXON|IXOFF|IXANY);
tio.c_lflag &= ~(ECHO|ECHOE|ECHOK|ECHONL|TOSTOP);
- tcsetattr(STDIN_FILENO, TCSANOW, &tio);
+ tcsetattr_stdin_TCSANOW(&tio);
memset(&sa, 0, sizeof(sa));
/* sa.sa_flags = 0; - no SA_RESTART! */
}
sigaction_set(SIGINT, &oldsa);
- tcsetattr(STDIN_FILENO, TCSANOW, &oldtio);
+ tcsetattr_stdin_TCSANOW(&oldtio);
bb_putchar('\n');
fflush(stdout);
return ret;
/* From <linux/kd.h> */
enum { KDGKBTYPE = 0x4B33 }; /* get keyboard type */
-
static int open_a_console(const char *fnam)
{
int fd;
* We try several things because opening /dev/console will fail
* if someone else used X (which does a chown on /dev/console).
*/
-
int FAST_FUNC get_console_fd_or_die(void)
{
static const char *const console_names[] = {
#define _POSIX_VDISABLE '\0'
#endif
new_settings.c_cc[VINTR] = _POSIX_VDISABLE;
- tcsetattr(STDIN_FILENO, TCSANOW, &new_settings);
+ tcsetattr_stdin_TCSANOW(&new_settings);
/* Now initialize things */
previous_SIGWINCH_handler = signal(SIGWINCH, win_changed);
#endif
/* restore initial_settings */
- tcsetattr(STDIN_FILENO, TCSANOW, &initial_settings);
+ tcsetattr_stdin_TCSANOW(&initial_settings);
/* restore SIGWINCH handler */
signal(SIGWINCH, previous_SIGWINCH_handler);
fflush(stdout);
return ret;
}
+
+int FAST_FUNC tcsetattr_stdin_TCSANOW(const struct termios *tp)
+{
+ return tcsetattr(STDIN_FILENO, TCSANOW, tp);
+}
*/
#ifdef __linux__
/* flush input and output queues, important for modems! */
- ioctl(0, TCFLSH, TCIOFLUSH);
+ ioctl(0, TCFLSH, TCIOFLUSH); /* tcflush(0, TCIOFLUSH)? - same */
#endif
tp->c_cflag = CS8 | HUPCL | CREAD | speed;
tp->c_cflag |= CRTSCTS;
#endif
- ioctl(0, TCSETS, tp);
+ tcsetattr_stdin_TCSANOW(tp);
debug("term_io 2\n");
}
tp->c_iflag |= ISTRIP; /* enable 8th-bit stripping */
vmin = tp->c_cc[VMIN];
tp->c_cc[VMIN] = 0; /* don't block if queue empty */
- ioctl(0, TCSETS, tp);
+ tcsetattr_stdin_TCSANOW(tp);
/*
* Wait for a while, then read everything the modem has said so far and
/* Restore terminal settings. Errors will be dealt with later on. */
tp->c_iflag = iflag;
tp->c_cc[VMIN] = vmin;
- ioctl(0, TCSETS, tp);
+ tcsetattr_stdin_TCSANOW(tp);
}
/* do_prompt - show login prompt, optionally preceded by /etc/issue contents */
/* Flush pending input (esp. after parsing or switching the baud rate). */
sleep(1);
- ioctl(0, TCFLSH, TCIFLUSH);
+ ioctl(0, TCFLSH, TCIFLUSH); /* tcflush(0, TCIOFLUSH)? - same */
/* Prompt for and read a login name. */
logname[0] = '\0';
}
#endif
/* Optionally enable hardware flow control */
-#ifdef CRTSCTS
+#ifdef CRTSCTS
if (op->flags & F_RTSCTS)
tp->c_cflag |= CRTSCTS;
#endif
/* Finally, make the new settings effective */
+ /* It's tcsetattr_stdin_TCSANOW() + error check */
ioctl_or_perror_and_die(0, TCSETS, tp, "%s: TCSETS", op->tty);
}
* by patching the SunOS kernel variable "zsadtrlow" to a larger value;
* 5 seconds seems to be a good value.
*/
+ /* tcgetattr() + error check */
ioctl_or_perror_and_die(0, TCGETS, &termios, "%s: TCGETS", options.tty);
#ifdef __linux__
baud_index = (baud_index + 1) % options.numspeed;
termios.c_cflag &= ~CBAUD;
termios.c_cflag |= options.speeds[baud_index];
- ioctl(0, TCSETS, &termios);
+ tcsetattr_stdin_TCSANOW(&termios);
}
}
term.c_iflag |= IGNBRK;
term.c_lflag &= ~ISIG;
term.c_lflag &= ~(ECHO | ECHOCTL);
- tcsetattr(STDIN_FILENO, TCSANOW, &term);
+ tcsetattr_stdin_TCSANOW(&term);
do {
printf("Virtual console%s locked by %s.\n",
} while (1);
ioctl(STDIN_FILENO, VT_SETMODE, &ovtm);
- tcsetattr(STDIN_FILENO, TCSANOW, &oterm);
+ tcsetattr_stdin_TCSANOW(&oterm);
fflush_stdout_and_exit(EXIT_SUCCESS);
}
termbuf.c_iflag |= ICRNL;
termbuf.c_iflag &= ~IXOFF;
/*termbuf.c_lflag &= ~ICANON;*/
- tcsetattr(0, TCSANOW, &termbuf);
+ tcsetattr_stdin_TCSANOW(&termbuf);
/* Uses FILE-based I/O to stdout, but does fflush(stdout),
* so should be safe with vfork.
static void reset_term(void)
{
- tcsetattr(0, TCSANOW, &initial_settings);
+ tcsetattr_stdin_TCSANOW(&initial_settings);
if (ENABLE_FEATURE_CLEAN_UP) {
clearmems();
#if ENABLE_FEATURE_TOP_CPU_USAGE_PERCENTAGE
new_settings.c_lflag &= ~(ISIG | ICANON | ECHO | ECHONL);
bb_signals(BB_FATAL_SIGS, sig_catcher);
- tcsetattr(0, TCSANOW, (void *) &new_settings);
+ tcsetattr_stdin_TCSANOW(&new_settings);
#endif /* FEATURE_USE_TERMIOS */
#if ENABLE_FEATURE_TOP_CPU_USAGE_PERCENTAGE
static void die(const char *str)
{
if (termios_set)
- tcsetattr(0, TCSANOW, &sv_termios);
+ tcsetattr_stdin_TCSANOW(&sv_termios);
bb_error_msg_and_die("%s", str);
}
tcgetattr(0, &sv_termios);
tmp = sv_termios;
tmp.c_lflag &= ~(ICANON | ECHO);
- tcsetattr(0, TCSANOW, &tmp);
+ tcsetattr_stdin_TCSANOW(&tmp);
termios_set = 1;
}
write_superblock();
if (OPT_manual)
- tcsetattr(0, TCSANOW, &sv_termios);
+ tcsetattr_stdin_TCSANOW(&sv_termios);
if (changed)
retcode += 3;