terminal-util: introduce vt_release() helper
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -155,3 +155,4 @@ int open_terminal_in_namespace(pid_t pid, const char *name, int mode);
|
||||
int vt_default_utf8(void);
|
||||
int vt_reset_keyboard(int fd);
|
||||
int vt_restore(int fd);
|
||||
int vt_release(int fd, bool restore_vt);
|
||||
|
||||
Reference in New Issue
Block a user