diff options
author | Robert Ancell <robert.ancell@canonical.com> | 2014-02-26 11:12:22 +1300 |
---|---|---|
committer | Robert Ancell <robert.ancell@canonical.com> | 2014-02-26 11:12:22 +1300 |
commit | 2b899d2c371eaeed3181a94a37266e8374e8a45f (patch) | |
tree | 4aa007faa44944a91ffdbb5598dcd51340d51525 /src/session.c | |
parent | eb669026e7fd106bd9bb176110b308562801b409 (diff) | |
download | lightdm-2b899d2c371eaeed3181a94a37266e8374e8a45f.tar.gz |
Be extra careful not to call any non thread safe function after a fork
Diffstat (limited to 'src/session.c')
-rw-r--r-- | src/session.c | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/src/session.c b/src/session.c index bc3928be..88616f53 100644 --- a/src/session.c +++ b/src/session.c @@ -549,6 +549,7 @@ session_real_start (Session *session) int version; int to_child_pipe[2], from_child_pipe[2]; int to_child_output, from_child_input; + gchar *arg0, *arg1; g_return_val_if_fail (session->priv->pid == 0, FALSE); @@ -581,24 +582,26 @@ session_real_start (Session *session) } /* Run the child */ + arg0 = g_strdup_printf ("%d", to_child_output); + arg1 = g_strdup_printf ("%d", from_child_input); session->priv->pid = fork (); - if (session->priv->pid < 0) - { - g_debug ("Failed to fork session child process: %s", strerror (errno)); - return FALSE; - } - if (session->priv->pid == 0) { /* Run us again in session child mode */ execlp ("lightdm", "lightdm", "--session-child", - g_strdup_printf ("%d", to_child_output), - g_strdup_printf ("%d", from_child_input), - NULL); + arg0, arg1, NULL); _exit (EXIT_FAILURE); } + g_free (arg0); + g_free (arg1); + + if (session->priv->pid < 0) + { + g_debug ("Failed to fork session child process: %s", strerror (errno)); + return FALSE; + } /* Hold a reference on this object until the child process terminates so we * can handle the watch callback even if it is no longer used. Otherwise a |