terminal-util: introduce vt_release() helper

This commit is contained in:
Franck Bui
2018-11-21 14:28:34 +01:00
parent ad96887a12
commit 27dafac92b
3 changed files with 19 additions and 2 deletions
+16
View File
@@ -1305,3 +1305,19 @@ int vt_restore(int fd) {
return q;
}
int vt_release(int fd, bool restore) {
assert(fd >= 0);
/* This function releases the VT by acknowledging the VT-switch signal
* sent by the kernel and optionally reset the VT in text and auto
* VT-switching modes. */
if (ioctl(fd, VT_RELDISP, 1) < 0)
return -errno;
if (restore)
return vt_restore(fd);
return 0;
}