Merge lp:~marmuta/unity-greeter/kill-onboard-with-sigterm into lp:unity-greeter

Proposed by marmuta
Status: Needs review
Proposed branch: lp:~marmuta/unity-greeter/kill-onboard-with-sigterm
Merge into: lp:unity-greeter
Diff against target: 105 lines (+53/-4)
3 files modified
src/main-window.vala (+5/-0)
src/menubar.vala (+46/-4)
src/unity-greeter.vala (+2/-0)
To merge this branch: bzr merge lp:~marmuta/unity-greeter/kill-onboard-with-sigterm
Reviewer Review Type Date Requested Status
Unity Greeter Development Team Pending
Review via email: mp+101889@code.launchpad.net

Description of the change

Kill Onboard with SIGTERM and let it release pressed keys, see bug #978430. On failure time out and kill it with SIGKILL as before.

$ tail /var/log/lightdm/x-0-greeter.log
[+13.48s] DEBUG: Authentication complete for user user with return code 0
[+13.49s] DEBUG: menubar.vala:208: Killing Onboard
[+13.49s] DEBUG: menubar.vala:24: sending SIGTERM to pid 16263
[+13.54s] DEBUG: menubar.vala:41: child 16263 exited status 0
[+13.54s] DEBUG: Starting session ubuntu
[+13.54s] DEBUG: Wrote 18 bytes to daemon
[+13.54s] DEBUG: Read 8 bytes from daemon
[+13.54s] DEBUG: Read 4 bytes from daemon

The call to main_window.before_session_start() in unity-greeter.vala is just a suggestion. I didn't find a better spot that is reliably called when the greeter is shut down. I've tried to just change the kill statement in the destructor of MenuBar, but apparently it is never reached when starting a session. It looks like the greeter is killed and Onboard with it before any cleanup is done.

To post a comment you must log in.

Unmerged revisions

386. By marmuta

Kill Onboard with SIGTERM to allow it to release still pressed keys, e.g. Return (LP: #978430).

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/main-window.vala'
--- src/main-window.vala 2012-03-13 14:27:50 +0000
+++ src/main-window.vala 2012-04-13 10:37:25 +0000
@@ -93,6 +93,11 @@
93 }93 }
94 }94 }
9595
96 public void before_session_start()
97 {
98 menubar.kill_onboard();
99 }
100
96 private void monitors_changed_cb (Gdk.Screen screen)101 private void monitors_changed_cb (Gdk.Screen screen)
97 {102 {
98 debug ("Screen is %dx%d pixels", screen.get_width (), screen.get_height ());103 debug ("Screen is %dx%d pixels", screen.get_width (), screen.get_height ());
99104
=== modified file 'src/menubar.vala'
--- src/menubar.vala 2012-03-21 20:00:39 +0000
+++ src/menubar.vala 2012-04-13 10:37:25 +0000
@@ -18,6 +18,43 @@
18 * Michael Terry <michael.terry@canonical.com>18 * Michael Terry <michael.terry@canonical.com>
19 */19 */
2020
21class Terminator
22{
23 public static void terminate(Pid pid) {
24 debug("sending SIGTERM to pid %u", pid);
25 Posix.kill (pid, Posix.SIGTERM);
26 if (waitpid_timeout(pid) == 0)
27 {
28 debug("sending SIGKILL to pid %u", pid);
29 Posix.kill (pid, Posix.SIGKILL);
30 waitpid_timeout(pid);
31 }
32 Process.close_pid (pid);
33 }
34
35 private static int waitpid_timeout(Pid pid, int timeout = 3)
36 {
37 int result = 0;
38 MainLoop loop = new MainLoop();
39
40 ChildWatch.add (pid, (pid, status) => {
41 debug("child %u exited status %d", pid, status);
42 loop.quit();
43 result = pid;
44 });
45
46 Timeout.add_seconds(timeout, () => {
47 debug("child timed out!");
48 loop.quit();
49 return false;
50 });
51
52 loop.run();
53
54 return result;
55 }
56}
57
21private class IndicatorMenuItem : Gtk.MenuItem58private class IndicatorMenuItem : Gtk.MenuItem
22{59{
23 public unowned Indicator.ObjectEntry entry;60 public unowned Indicator.ObjectEntry entry;
@@ -161,11 +198,15 @@
161198
162 ~MenuBar ()199 ~MenuBar ()
163 {200 {
201 kill_onboard();
202 }
203
204 public void kill_onboard()
205 {
164 if (keyboard_pid != 0)206 if (keyboard_pid != 0)
165 {207 {
166 Posix.kill (keyboard_pid, Posix.SIGKILL);208 debug("Killing Onboard");
167 int status;209 Terminator.terminate(keyboard_pid);
168 Posix.waitpid (keyboard_pid, out status, 0);
169 keyboard_pid = 0;210 keyboard_pid = 0;
170 }211 }
171 }212 }
@@ -358,7 +399,8 @@
358 Process.spawn_async_with_pipes (null,399 Process.spawn_async_with_pipes (null,
359 argv,400 argv,
360 null,401 null,
361 SpawnFlags.SEARCH_PATH,402 SpawnFlags.SEARCH_PATH |
403 SpawnFlags.DO_NOT_REAP_CHILD,
362 null,404 null,
363 out keyboard_pid,405 out keyboard_pid,
364 null,406 null,
365407
=== modified file 'src/unity-greeter.vala'
--- src/unity-greeter.vala 2012-03-27 06:00:03 +0000
+++ src/unity-greeter.vala 2012-04-13 10:37:25 +0000
@@ -407,6 +407,8 @@
407 c = null;407 c = null;
408 refresh_background (Gdk.Screen.get_default (), background_surface);408 refresh_background (Gdk.Screen.get_default (), background_surface);
409409
410 main_window.before_session_start();
411
410 try412 try
411 {413 {
412 greeter.start_session_sync (user_list.session);414 greeter.start_session_sync (user_list.session);

Subscribers

People subscribed via source and target branches