summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans de Goede <hdegoede@redhat.com>2011-04-19 16:24:48 +0200
committerHans de Goede <hdegoede@redhat.com>2011-04-19 16:26:17 +0200
commit4564cbb59dd1d187e55af0f98d0086dad1cf72c6 (patch)
tree7d1ebfac2a626e2b460fb7f281055ef9b759056c
parent9bd22a5c99fa4f5bea621926dda3989e0030c281 (diff)
vdagent: connect to vdagentd after daemonizing
Doing this before daemonizing leads to the vdagentd seeing the connection from the pid of the mother, which may have exited by the time vdagent asks consolekit GetSessionForUnixProcess for the pid, resulting in an error.
-rw-r--r--src/vdagent.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/src/vdagent.c b/src/vdagent.c
index 2a72adb..3569cdb 100644
--- a/src/vdagent.c
+++ b/src/vdagent.c
@@ -106,7 +106,6 @@ void daemonize(void)
fprintf(logfile, "fork: %s\n", strerror(errno));
retval = 1;
default:
- udscs_destroy_connection(&client);
if (logfile != stderr)
fclose(logfile);
exit(retval);
@@ -166,6 +165,9 @@ int main(int argc, char *argv[])
fprintf(stderr, "Could not get home directory, logging to stderr\n");
}
+ if (do_daemonize)
+ daemonize();
+
client = udscs_connect(VDAGENTD_SOCKET, daemon_read_complete, NULL,
vdagentd_messages, VDAGENTD_NO_MESSAGES,
verbose? logfile:NULL, logfile);
@@ -175,9 +177,6 @@ int main(int argc, char *argv[])
return 1;
}
- if (do_daemonize)
- daemonize();
-
x11 = vdagent_x11_create(client, logfile, verbose);
if (!x11) {
udscs_destroy_connection(&client);