gnome-settings-daemon r585 - in trunk: . gnome-settings-daemon
- From: behdad svn gnome org
- To: svn-commits-list gnome org
- Subject: gnome-settings-daemon r585 - in trunk: . gnome-settings-daemon
- Date: Tue, 4 Nov 2008 08:14:29 +0000 (UTC)
Author: behdad
Date: Tue Nov 4 08:14:29 2008
New Revision: 585
URL: http://svn.gnome.org/viewvc/gnome-settings-daemon?rev=585&view=rev
Log:
2008-11-04 Behdad Esfahbod <behdad gnome org>
* gnome-settings-daemon/main.c (daemonize), (main): Use a pipe
to communicate between child and parent process instead of a
signal. Signals are not queued, so if the child tried to signal
the parent before the parent got a chance to wait for it, the signal
would be lost and parent wait indefinitely for a signal that would
never arrive.
Modified:
trunk/ChangeLog
trunk/gnome-settings-daemon/main.c
Modified: trunk/gnome-settings-daemon/main.c
==============================================================================
--- trunk/gnome-settings-daemon/main.c (original)
+++ trunk/gnome-settings-daemon/main.c Tue Nov 4 08:14:29 2008
@@ -47,6 +47,7 @@
static char *gconf_prefix = NULL;
static gboolean no_daemon = FALSE;
static gboolean debug = FALSE;
+static int pipefds[2];
static GOptionEntry entries[] = {
{"debug", 0, 0, G_OPTION_ARG_NONE, &debug, N_("Enable debugging code"), NULL },
@@ -230,7 +231,10 @@
daemonize (void)
{
int child_pid;
+ char buf[1];
+ signal (SIGPIPE, SIG_IGN);
+ pipe (pipefds);
child_pid = fork ();
switch (child_pid) {
@@ -251,17 +255,16 @@
chdir ("/");
umask (0117);
+ close (pipefds[0]);
+
return TRUE;
default:
/* parent */
- /* Wait for child to signal that we are good to go.
- * We actully are just waiting for the child to send
- * us a signal, any signal, not for it to quit. Any
- * signal received from any process gets us out of the
- * wait with EINTR, and that's fine. */
- waitpid (child_pid, NULL, 0);
+ close (pipefds[1]);
+ /* Wait for child to signal that we are good to go. */
+ read (pipefds[0], buf, 1);
exit (EXIT_SUCCESS);
}
@@ -353,7 +356,8 @@
* process and continue using from the other. So, we just made the
* parent to fork early and wait. */
if (! no_daemon) {
- kill (getppid (), SIGCHLD);
+ write (pipefds[1], "1", 1);
+ close (pipefds[1]);
gnome_settings_profile_end ("daemon initialization");
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]