CTRL-C caused the weston process to exit 74/33674/1 accepted/tizen/common/20150114.145648 accepted/tizen/mobile/20150114.232349 accepted/tizen/tv/20150115.004609 accepted/tizen/wearable/20150115.004851 submit/tizen/20150114.141353
authorImran Zaman <imran.zaman@intel.com>
Tue, 13 Jan 2015 15:25:26 +0000 (17:25 +0200)
committerImran Zaman <imran.zaman@intel.com>
Tue, 13 Jan 2015 17:02:52 +0000 (19:02 +0200)
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 <imran.zaman@intel.com>
src/daemon/tlm-main.c
src/sessiond/main.c
src/sessiond/tlm-session.c
src/utils/tlm-client.c

index dfd92ec..6eca469 100644 (file)
@@ -24,9 +24,6 @@
  * 02110-1301 USA
  */
 
-#include <string.h>
-#include <signal.h>
-#include <errno.h>
 #include <glib.h>
 #include <gio/gio.h>
 #include <glib-unix.h>
@@ -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);
 }
 
index a8ab109..bf5ed9d 100644 (file)
@@ -28,7 +28,6 @@
 #include <signal.h>
 #include <string.h>
 #include <stdio.h>
-#include <errno.h>
 #include <glib-unix.h>
 #include <glib.h>
 #include <gio/gio.h>
@@ -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");
 }
index afdaa1b..976ddc7 100644 (file)
@@ -33,7 +33,6 @@
 #include <grp.h>
 #include <stdio.h>
 #include <signal.h>
-#include <errno.h>
 #include <termios.h>
 #include <libintl.h>
 #include <sys/types.h>
@@ -43,6 +42,7 @@
 #include <ctype.h>
 #include <sys/socket.h>
 #include <netdb.h>
+#include <linux/kd.h>
 
 #include <glib.h>
 #include <glib/gstdio.h>
@@ -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) {
index e52ee78..4f9128f 100644 (file)
@@ -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) {