diff options
author | Bill Nottingham <notting@redhat.com> | 1999-10-25 21:30:32 +0000 |
---|---|---|
committer | Bill Nottingham <notting@redhat.com> | 1999-10-25 21:30:32 +0000 |
commit | a3eb45ccdb83d9afdcca5c1c8c0ac7b99f2d5616 (patch) | |
tree | 2396dff09c5836c2dcc93f0a3b72854d7e7ff7c0 /src/consoletype.c | |
parent | 1cdcdf23deae9d776966f60f5a24c5c624cd0073 (diff) | |
download | initscripts-a3eb45ccdb83d9afdcca5c1c8c0ac7b99f2d5616.tar initscripts-a3eb45ccdb83d9afdcca5c1c8c0ac7b99f2d5616.tar.gz initscripts-a3eb45ccdb83d9afdcca5c1c8c0ac7b99f2d5616.tar.bz2 initscripts-a3eb45ccdb83d9afdcca5c1c8c0ac7b99f2d5616.tar.xz initscripts-a3eb45ccdb83d9afdcca5c1c8c0ac7b99f2d5616.zip |
fix console checking with new consoletype program (from jakub)
Diffstat (limited to 'src/consoletype.c')
-rw-r--r-- | src/consoletype.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/consoletype.c b/src/consoletype.c new file mode 100644 index 00000000..6bfda4bd --- /dev/null +++ b/src/consoletype.c @@ -0,0 +1,27 @@ +#include <stdio.h> +#include <string.h> +#include <sys/ioctl.h> +#include <sys/stat.h> +#include <sys/sysmacros.h> + +int main(int argc, char **argv) +{ + unsigned char twelve = 12; + int maj; + struct stat sb; + + fstat(0, &sb); + maj = major(sb.st_rdev); + if (maj != 3 && (maj < 136 || maj > 143)) { + if (ioctl (0, TIOCLINUX, &twelve) < 0) { + printf ("serial\n"); + return 1; + } else { + printf ("vt\n"); + return 0; + } + } else { + printf ("pty\n"); + return 2; + } +} |