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

Proposed by marmuta on 2012-04-13
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 2012-04-13 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 on 2012-04-13

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
1=== modified file 'src/main-window.vala'
2--- src/main-window.vala 2012-03-13 14:27:50 +0000
3+++ src/main-window.vala 2012-04-13 10:37:25 +0000
4@@ -93,6 +93,11 @@
5 }
6 }
7
8+ public void before_session_start()
9+ {
10+ menubar.kill_onboard();
11+ }
12+
13 private void monitors_changed_cb (Gdk.Screen screen)
14 {
15 debug ("Screen is %dx%d pixels", screen.get_width (), screen.get_height ());
16
17=== modified file 'src/menubar.vala'
18--- src/menubar.vala 2012-03-21 20:00:39 +0000
19+++ src/menubar.vala 2012-04-13 10:37:25 +0000
20@@ -18,6 +18,43 @@
21 * Michael Terry <michael.terry@canonical.com>
22 */
23
24+class Terminator
25+{
26+ public static void terminate(Pid pid) {
27+ debug("sending SIGTERM to pid %u", pid);
28+ Posix.kill (pid, Posix.SIGTERM);
29+ if (waitpid_timeout(pid) == 0)
30+ {
31+ debug("sending SIGKILL to pid %u", pid);
32+ Posix.kill (pid, Posix.SIGKILL);
33+ waitpid_timeout(pid);
34+ }
35+ Process.close_pid (pid);
36+ }
37+
38+ private static int waitpid_timeout(Pid pid, int timeout = 3)
39+ {
40+ int result = 0;
41+ MainLoop loop = new MainLoop();
42+
43+ ChildWatch.add (pid, (pid, status) => {
44+ debug("child %u exited status %d", pid, status);
45+ loop.quit();
46+ result = pid;
47+ });
48+
49+ Timeout.add_seconds(timeout, () => {
50+ debug("child timed out!");
51+ loop.quit();
52+ return false;
53+ });
54+
55+ loop.run();
56+
57+ return result;
58+ }
59+}
60+
61 private class IndicatorMenuItem : Gtk.MenuItem
62 {
63 public unowned Indicator.ObjectEntry entry;
64@@ -161,11 +198,15 @@
65
66 ~MenuBar ()
67 {
68+ kill_onboard();
69+ }
70+
71+ public void kill_onboard()
72+ {
73 if (keyboard_pid != 0)
74 {
75- Posix.kill (keyboard_pid, Posix.SIGKILL);
76- int status;
77- Posix.waitpid (keyboard_pid, out status, 0);
78+ debug("Killing Onboard");
79+ Terminator.terminate(keyboard_pid);
80 keyboard_pid = 0;
81 }
82 }
83@@ -358,7 +399,8 @@
84 Process.spawn_async_with_pipes (null,
85 argv,
86 null,
87- SpawnFlags.SEARCH_PATH,
88+ SpawnFlags.SEARCH_PATH |
89+ SpawnFlags.DO_NOT_REAP_CHILD,
90 null,
91 out keyboard_pid,
92 null,
93
94=== modified file 'src/unity-greeter.vala'
95--- src/unity-greeter.vala 2012-03-27 06:00:03 +0000
96+++ src/unity-greeter.vala 2012-04-13 10:37:25 +0000
97@@ -407,6 +407,8 @@
98 c = null;
99 refresh_background (Gdk.Screen.get_default (), background_surface);
100
101+ main_window.before_session_start();
102+
103 try
104 {
105 greeter.start_session_sync (user_list.session);

Subscribers

People subscribed via source and target branches