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
=== modified file 'src/process.c'
--- src/process.c 2014-03-04 03:23:30 +0000
+++ src/process.c 2014-03-05 22:35:48 +0000
@@ -55,6 +55,9 @@
55 /* Exit status of process */55 /* Exit status of process */
56 int exit_status;56 int exit_status;
5757
58 /* TRUE if stopping this process (waiting for child process to stop) */
59 gboolean stopping;
60
58 /* Timeout waiting for process to quit */61 /* Timeout waiting for process to quit */
59 guint quit_timeout;62 guint quit_timeout;
6063
@@ -292,7 +295,11 @@
292 g_debug ("Sending signal %d to process %d", signum, process->priv->pid);295 g_debug ("Sending signal %d to process %d", signum, process->priv->pid);
293296
294 if (kill (process->priv->pid, signum) < 0)297 if (kill (process->priv->pid, signum) < 0)
295 g_warning ("Error sending signal %d to process %d: %s", signum, process->priv->pid, strerror (errno));298 {
299 /* Ignore ESRCH, we will pick that up in our wait */
300 if (errno != ESRCH)
301 g_warning ("Error sending signal %d to process %d: %s", signum, process->priv->pid, strerror (errno));
302 }
296}303}
297304
298static gboolean305static gboolean
@@ -308,6 +315,14 @@
308{315{
309 g_return_if_fail (process != NULL);316 g_return_if_fail (process != NULL);
310317
318 if (process->priv->stopping)
319 return;
320 process->priv->stopping = TRUE;
321
322 /* If already stopped then we're done! */
323 if (process->priv->pid == 0)
324 return;
325
311 /* Send SIGTERM, and then SIGKILL if no response */326 /* Send SIGTERM, and then SIGKILL if no response */
312 process->priv->quit_timeout = g_timeout_add (5000, (GSourceFunc) quit_timeout_cb, process);327 process->priv->quit_timeout = g_timeout_add (5000, (GSourceFunc) quit_timeout_cb, process);
313 process_signal (process, SIGTERM);328 process_signal (process, SIGTERM);

Subscribers

People subscribed via source and target branches