feat(chvt): use custom implementation instead of system()

Calling system() is vulnerable and shouldn't be used.
This commit is contained in:
grialion
2024-08-06 17:11:18 +02:00
parent eeba4a5f39
commit e745b27a68
4 changed files with 53 additions and 9 deletions

21
include/chvt.h Normal file
View File

@@ -0,0 +1,21 @@
#ifndef _CHVTH_
#define _CHVTH_
#include <fcntl.h>
#include <stdio.h>
#include <sys/ioctl.h>
#include <unistd.h>
#define KDGKBTYPE 0x4b33
#define VT_ACTIVATE 0x5606
#define VT_WAITACTIVE 0x5607
/**
* @brief change foreground virtual terminal to `n`
*
* @param n virtual terminal number
* @return int non-negative value on success
*/
int chvt(int n);
#endif