#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;
signal_main_thread();
return NULL;
}
+ g_have_x = 1;
screen = DefaultScreen(display);
pthread_t tid;
int ret;
+ if (argc < 2) {
+ printf("usage:\n%s <app> [arg]..\n", argv[0]);
+ return 1;
+ }
+
pthread_mutex_lock(&g_start_mutex);
ret = pthread_create(&tid, NULL, x11_handler, NULL);
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? */