From ecd410d3e9cf436570b2c4efb92056ce4ada4666 Mon Sep 17 00:00:00 2001 From: Grazvydas Ignotas Date: Mon, 9 Apr 2012 21:52:09 +0300 Subject: [PATCH] op_runfbapp: don't do console when under X --- op_runfbapp.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/op_runfbapp.c b/op_runfbapp.c index 495b493..da0a1c8 100644 --- a/op_runfbapp.c +++ b/op_runfbapp.c @@ -43,7 +43,8 @@ #define PFX "op_runfbapp: " static struct termios g_kbd_termios_saved; -static int g_kbdfd; +static int g_kbdfd = -1; +static int g_have_x; static pthread_cond_t g_start_cond = PTHREAD_COND_INITIALIZER; static pthread_mutex_t g_start_mutex = PTHREAD_MUTEX_INITIALIZER; @@ -86,6 +87,7 @@ static void *x11_handler(void *arg) signal_main_thread(); return NULL; } + g_have_x = 1; screen = DefaultScreen(display); @@ -209,6 +211,11 @@ int main(int argc, char *argv[]) pthread_t tid; int ret; + if (argc < 2) { + printf("usage:\n%s [arg]..\n", argv[0]); + return 1; + } + pthread_mutex_lock(&g_start_mutex); ret = pthread_create(&tid, NULL, x11_handler, NULL); @@ -221,11 +228,13 @@ int main(int argc, char *argv[]) pthread_cond_wait(&g_start_cond, &g_start_mutex); pthread_mutex_unlock(&g_start_mutex); - hidecon_start(); + if (!g_have_x) + hidecon_start(); do_exec(argv + 1); - hidecon_end(); + if (!g_have_x) + hidecon_end(); /* XXX: maybe stop the X thread nicely? */ -- 2.39.5