确定是否在illumos / solaris的控制台上运行

时间:2013-05-02 17:42:41

标签: c console solaris x11

Debian的X包装器中使用了a function。此函数确定X是否在控制台(虚拟终端)上运行,它适用于linux和freebsd。

在illumos / solaris上有什么方法可以做同样的事情?

2 个答案:

答案 0 :(得分:2)

VT_GETSTATE ioctl可用于确定Solaris 11上的活动VT。有关详细信息,请参阅vt(7I) man page

答案 1 :(得分:0)

diff --git a/debian/local/xserver-wrapper.c b/debian/local/xserver-wrapper.c
index d4a6ab8..31e5343 100644
--- a/debian/local/xserver-wrapper.c
+++ b/debian/local/xserver-wrapper.c
@@ -116,6 +116,9 @@
 #define TTY_MAJOR_DEV 4
 #elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
 #include <sys/consio.h>
+#elif defined(__sun__)
+#include <sys/kd.h>
+#include <sys/vt.h>
 #endif

 #define X_WRAPPER_CONFIG_FILE "/etc/X11/Xwrapper.config" 
@@ -171,6 +174,10 @@ onConsole()

   if (ioctl(0, VT_GETINDEX, &idx) != -1)
     return TRUE;
+#elif defined(__sun__)
+  int mode;
+  if (ioctl(0, KDGETMODE, &mode) != -1) /* mode = 0 (KD_TEXT) or 1 (KD_GRAPHICS) */
+    return TRUE;
 #else
 #warning This program needs porting to your kernel.
   (void) fprintf(stderr, "X: unable to determine if running on a console\n");