Bug#614127: confirmed on allmachines: painfull
On Fri, Feb 25, 2011 at 20:20:47 +0200, Anton Zinoviev wrote:
> On Fri, Feb 25, 2011 at 06:44:22PM +0100, Julien Cristau wrote:
> >
> > Why "at best"? It sounds like checking whether the active VT is in
> > KD_TEXT is exactly what's needed here.
>
> How can this be tested?
>
Something like this:
#include <stdio.h>
#include <err.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <linux/kd.h>
int main() {
int fd;
int rc;
int mode;
fd = open("/dev/tty0", O_RDONLY);
if (fd < 0)
err(1, "open(/dev/tty0)");
rc = ioctl(fd, KDGETMODE, &mode);
if (rc < 0)
err(1, "ioctl(KDGETMODE)");
switch (mode) {
case KD_TEXT:
printf("text\n");
break;
case KD_GRAPHICS:
printf("graphics\n");
break;
default:
printf("other (%d)\n", mode);
break;
}
return 0;
}
Reply to: