--- kon2-0.3.9b.orig/src/main.c
+++ kon2-0.3.9b/src/main.c
@@ -30,15 +30,42 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
+#include <sys/stat.h>
+#include <sys/sysmacros.h>
+#if defined(linux)
+#include <linux/major.h>
+#endif
 
 #include <getcap.h>
 
 #include <version.h>
 #include <term.h>
 
-void
+void KonInit ();
+void KonStart ();
+
+int
+check_tty ()
+{
+    struct stat device_stat;
+
+    if (stat(ttyname(STDIN_FILENO), &device_stat) == -1)
+	return -1;
+    if (major(device_stat.st_rdev) != TTY_MAJOR)
+	return -1;
+
+    return 0;
+}
+
+int
 main(int argc, const char *argv[])
 {
+
+    if (check_tty ()) {
+	fprintf(stderr, "You can run this Kon at only console terminal.\n");
+	exit(EXIT_FAILURE);
+    }
+
 #ifdef	MINI_KON
     fprintf(stderr, "Kanji ON Console MINI " VERSION "\n\n");
 #else
@@ -50,4 +77,6 @@
     }
     KonInit(argc - 1, argv + 1);
     KonStart(TRUE);
+
+    return 0;
 }
