1
0
mirror of https://github.com/systemd/systemd.git synced 2024-11-02 19:21:53 +03:00

util: reset terminal even harder

This commit is contained in:
Lennart Poettering 2010-07-12 21:40:43 +02:00
parent 7bc0351dd8
commit 3fe5e5d476

View File

@ -47,6 +47,7 @@
#include <sys/utsname.h>
#include <pwd.h>
#include <netinet/ip.h>
#include <linux/kd.h>
#include "macro.h"
#include "util.h"
@ -1844,10 +1845,22 @@ int ask(char *ret, const char *replies, const char *text, ...) {
int reset_terminal(int fd) {
struct termios termios;
int r = 0;
long arg;
/* Set terminal to some sane defaults */
assert(fd >= 0);
/* Set terminal to some sane defaults */
/* First, unlock termios */
zero(termios);
ioctl(fd, TIOCSLCKTRMIOS, &termios);
/* Disable exclusive mode, just in case */
ioctl(fd, TIOCNXCL);
/* Enable console unicode mode */
arg = K_UNICODE;
ioctl(fd, KDSKBMODE, &arg);
if (tcgetattr(fd, &termios) < 0) {
r = -errno;