kiwi-el8/tools/isconsole/isconsole.c
Marcus Schäfer 09daca60c0
KIWI - appliance builder next generation
a rewrite of the current kiwi from https://github.com/openSUSE/kiwi
2015-12-05 16:17:10 +01:00

25 lines
490 B
C

#include <stdio.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <linux/kd.h>
#include <unistd.h>
#include <errno.h>
int main (void) {
int mode = 0;
int tty = open( "/dev/console", O_RDONLY );
if (tty < 0) {
// failed to open device
return 1;
}
int status = ioctl( tty, KDGETMODE, &mode );
close (tty);
if (status != 0) {
// ioctl returned error
return 1;
}
return 0;
}