summaryrefslogtreecommitdiff
path: root/src/util.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/util.c')
-rw-r--r--src/util.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/util.c b/src/util.c
index 7977ee46c5..e46606dabb 100644
--- a/src/util.c
+++ b/src/util.c
@@ -2307,8 +2307,10 @@ int chvt(int vt) {
0
};
- if (ioctl(fd, TIOCLINUX, tiocl) < 0)
- return -errno;
+ if (ioctl(fd, TIOCLINUX, tiocl) < 0) {
+ r = -errno;
+ goto fail;
+ }
vt = tiocl[0] <= 0 ? 1 : tiocl[0];
}
@@ -2316,7 +2318,8 @@ int chvt(int vt) {
if (ioctl(fd, VT_ACTIVATE, vt) < 0)
r = -errno;
- close_nointr_nofail(r);
+fail:
+ close_nointr_nofail(fd);
return r;
}