diff options
author | Lennart Poettering <lennart@poettering.net> | 2018-02-13 23:53:34 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2018-02-13 23:53:34 +0100 |
commit | 87964ec7d1c6edf69d18dba53add7d1b70a3aaf0 (patch) | |
tree | a929beec041b26f75cb713dca1c425d0e3893d31 /src/basic | |
parent | c6063244db32c0e1b0195e5d653d5e159db06bc7 (diff) | |
download | systemd-87964ec7d1c6edf69d18dba53add7d1b70a3aaf0.tar.gz |
terminal-util: minor, trivial fixes and improvements
Diffstat (limited to 'src/basic')
-rw-r--r-- | src/basic/terminal-util.c | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/src/basic/terminal-util.c b/src/basic/terminal-util.c index 40f8282e99..97c876af0c 100644 --- a/src/basic/terminal-util.c +++ b/src/basic/terminal-util.c @@ -327,8 +327,8 @@ int reset_terminal(const char *name) { } int open_terminal(const char *name, int mode) { - int fd, r; unsigned c = 0; + int fd; /* * If a TTY is in the process of being closed opening it might @@ -358,8 +358,7 @@ int open_terminal(const char *name, int mode) { c++; } - r = isatty(fd); - if (r == 0) { + if (isatty(fd) <= 0) { safe_close(fd); return -ENOTTY; } @@ -507,7 +506,7 @@ int release_terminal(void) { _cleanup_close_ int fd = -1; struct sigaction sa_old; - int r = 0; + int r; fd = open("/dev/tty", O_RDWR|O_NOCTTY|O_CLOEXEC|O_NONBLOCK); if (fd < 0) @@ -517,8 +516,7 @@ int release_terminal(void) { * by our own TIOCNOTTY */ assert_se(sigaction(SIGHUP, &sa_new, &sa_old) == 0); - if (ioctl(fd, TIOCNOTTY) < 0) - r = -errno; + r = ioctl(fd, TIOCNOTTY) < 0 ? -errno : 0; assert_se(sigaction(SIGHUP, &sa_old, NULL) == 0); |