Merge lp:~robert-ancell/lightdm/process-cleanup into lp:lightdm

Proposed by Robert Ancell
Status: Merged
Approved by: Robert Ancell
Approved revision: 1912
Merged at revision: 1913
Proposed branch: lp:~robert-ancell/lightdm/process-cleanup
Merge into: lp:lightdm
Diff against target: 41 lines (+16/-1)
1 file modified
src/process.c (+16/-1)
To merge this branch: bzr merge lp:~robert-ancell/lightdm/process-cleanup
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve
Robert Ancell Approve
Review via email: mp+209553@code.launchpad.net

Commit message

Make sure processes can only be stopped once, don't warn if process doesn't exist when sending it a signal (we will pick that up in the wait())

To post a comment you must log in.
Revision history for this message
Robert Ancell (robert-ancell) :
review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/process.c'
2--- src/process.c 2014-03-04 03:23:30 +0000
3+++ src/process.c 2014-03-05 22:35:48 +0000
4@@ -55,6 +55,9 @@
5 /* Exit status of process */
6 int exit_status;
7
8+ /* TRUE if stopping this process (waiting for child process to stop) */
9+ gboolean stopping;
10+
11 /* Timeout waiting for process to quit */
12 guint quit_timeout;
13
14@@ -292,7 +295,11 @@
15 g_debug ("Sending signal %d to process %d", signum, process->priv->pid);
16
17 if (kill (process->priv->pid, signum) < 0)
18- g_warning ("Error sending signal %d to process %d: %s", signum, process->priv->pid, strerror (errno));
19+ {
20+ /* Ignore ESRCH, we will pick that up in our wait */
21+ if (errno != ESRCH)
22+ g_warning ("Error sending signal %d to process %d: %s", signum, process->priv->pid, strerror (errno));
23+ }
24 }
25
26 static gboolean
27@@ -308,6 +315,14 @@
28 {
29 g_return_if_fail (process != NULL);
30
31+ if (process->priv->stopping)
32+ return;
33+ process->priv->stopping = TRUE;
34+
35+ /* If already stopped then we're done! */
36+ if (process->priv->pid == 0)
37+ return;
38+
39 /* Send SIGTERM, and then SIGKILL if no response */
40 process->priv->quit_timeout = g_timeout_add (5000, (GSourceFunc) quit_timeout_cb, process);
41 process_signal (process, SIGTERM);

Subscribers

People subscribed via source and target branches