From 4ee37d6b8c605762eac1b593359fc2c171765a7e Mon Sep 17 00:00:00 2001 From: Imran Zaman Date: Tue, 13 Jan 2015 17:25:26 +0200 Subject: [PATCH] CTRL-C caused the weston process to exit when Weston is active, any keyboard events should not go to the console. Instead, Weston open the evdev device, and get kbd input through that. Change-Id: Ie82b9d9e681422956979e9446b9eb765151b6c2e Fixed Bug TC-2318 Signed-off-by: Imran Zaman --- src/daemon/tlm-main.c | 9 ++------- src/sessiond/main.c | 15 +++++++++------ src/sessiond/tlm-session.c | 17 ++++++++++++----- src/utils/tlm-client.c | 4 +--- 4 files changed, 24 insertions(+), 21 deletions(-) diff --git a/src/daemon/tlm-main.c b/src/daemon/tlm-main.c index dfd92ec..6eca469 100644 --- a/src/daemon/tlm-main.c +++ b/src/daemon/tlm-main.c @@ -24,9 +24,6 @@ * 02110-1301 USA */ -#include -#include -#include #include #include #include @@ -54,7 +51,7 @@ _on_manager_stopped_cb (TlmManager *manager, gpointer user_data) static gboolean _on_sigterm_cb (gpointer data) { - DBG ("SIGTERM"); + DBG ("SIGTERM/SIGINT"); TlmManager *manager = TLM_MANAGER(data); @@ -81,10 +78,8 @@ _on_sighup_cb (gpointer data) static void _setup_unix_signal_handlers (TlmManager *manager) { - if (signal (SIGINT, SIG_IGN) == SIG_ERR) - WARN ("failed ignore SIGINT: %s", strerror(errno)); - g_unix_signal_add (SIGTERM, _on_sigterm_cb, (gpointer) manager); + g_unix_signal_add (SIGINT, _on_sigterm_cb, (gpointer) manager); g_unix_signal_add (SIGHUP, _on_sighup_cb, (gpointer) manager); } diff --git a/src/sessiond/main.c b/src/sessiond/main.c index a8ab109..bf5ed9d 100644 --- a/src/sessiond/main.c +++ b/src/sessiond/main.c @@ -28,7 +28,6 @@ #include #include #include -#include #include #include #include @@ -38,7 +37,7 @@ #include "tlm-session-daemon.h" static TlmSessionDaemon *_daemon = NULL; -static guint _sig_source_id[2]; +static guint _sig_source_id[3]; static void _on_daemon_closed (gpointer data, GObject *server) @@ -66,9 +65,6 @@ _install_sighandlers (GMainLoop *main_loop) GSource *source = NULL; GMainContext *ctx = g_main_loop_get_context (main_loop); - if (signal (SIGINT, SIG_IGN) == SIG_ERR) - WARN ("failed to ignore SIGINT: %s", strerror(errno)); - source = g_unix_signal_source_new (SIGTERM); g_source_set_callback (source, _handle_quit_signal, @@ -76,13 +72,20 @@ _install_sighandlers (GMainLoop *main_loop) NULL); _sig_source_id[0] = g_source_attach (source, ctx); - source = g_unix_signal_source_new (SIGHUP); + source = g_unix_signal_source_new (SIGINT); g_source_set_callback (source, _handle_quit_signal, main_loop, NULL); _sig_source_id[1] = g_source_attach (source, ctx); + source = g_unix_signal_source_new (SIGHUP); + g_source_set_callback (source, + _handle_quit_signal, + main_loop, + NULL); + _sig_source_id[2] = g_source_attach (source, ctx); + if (prctl(PR_SET_PDEATHSIG, SIGHUP)) WARN ("failed to set parent death signal"); } diff --git a/src/sessiond/tlm-session.c b/src/sessiond/tlm-session.c index afdaa1b..976ddc7 100644 --- a/src/sessiond/tlm-session.c +++ b/src/sessiond/tlm-session.c @@ -33,7 +33,6 @@ #include #include #include -#include #include #include #include @@ -43,6 +42,7 @@ #include #include #include +#include #include #include @@ -60,6 +60,10 @@ G_DEFINE_TYPE (TlmSession, tlm_session, G_TYPE_OBJECT); #define TLM_SESSION_PRIV(obj) \ G_TYPE_INSTANCE_GET_PRIVATE ((obj), TLM_TYPE_SESSION, TlmSessionPrivate) +#ifndef KDSKBMUTE +#define KDSKBMUTE 0x4B51 +#endif + enum { PROP_0, PROP_CONFIG, @@ -392,6 +396,13 @@ _set_terminal (TlmSessionPrivate *priv) if (ioctl (tty_fd, TIOCSPGRP, &tty_pgid)) { WARN ("ioctl(TIOCSPGRP) failed: %s", strerror(errno)); } + + /* TODO: unset the mode on session cleanup */ + if (ioctl(tty_fd, KDSKBMUTE, 1) && + ioctl(tty_fd, KDSKBMODE, K_OFF)) { + WARN ("ioctl(KDSKBMODE) failed: %s", strerror(errno)); + } + /*if (tcsetpgrp (tty_fd, getpgrp ())) WARN ("tcsetpgrp() failed: %s", strerror(errno));*/ @@ -562,7 +573,6 @@ _exec_user_session ( /* ================================== * this is child process here onwards * ================================== */ - gint open_max; gint fd; @@ -689,9 +699,6 @@ _exec_user_session ( args[1] = g_strdup ("--user"); } - if (signal (SIGINT, SIG_DFL) == SIG_ERR) - WARN ("failed reset SIGINT: %s", strerror(errno)); - DBG ("executing: "); args_iter = args; while (args_iter && *args_iter) { diff --git a/src/utils/tlm-client.c b/src/utils/tlm-client.c index e52ee78..4f9128f 100644 --- a/src/utils/tlm-client.c +++ b/src/utils/tlm-client.c @@ -168,11 +168,9 @@ _convert_environ_to_variant (gchar **env) { GVariant *venv = NULL; gchar **penv = env; - g_return_val_if_fail (env != NULL, NULL); - builder = g_variant_builder_new (((const GVariantType *) "a{ss}")); - while (*penv) { + while (penv && *penv) { gchar *key = *penv++; gchar *value = *penv++; if (!key || !value) { -- 2.7.4