From ba324d0f1fdee3e5f24618b4d590011007d417a2 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Mon, 1 Nov 2010 12:25:16 +0100 Subject: vdagentd: unlink socket on exit rather then startup This makes sure that the daemon cannot be started twice. --- udscs.c | 8 -------- vdagentd.c | 2 ++ 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/udscs.c b/udscs.c index 6f93648..b6caa4c 100644 --- a/udscs.c +++ b/udscs.c @@ -108,14 +108,6 @@ struct udscs_server *udscs_create_server(const char *socketname, return NULL; } - c = unlink(socketname); - if (c != 0 && errno != ENOENT) { - fprintf(server->errfile, "unlink %s: %s\n", socketname, - strerror(errno)); - free(server); - return NULL; - } - address.sun_family = AF_UNIX; snprintf(address.sun_path, sizeof(address.sun_path), "%s", socketname); c = bind(server->fd, (struct sockaddr *)&address, sizeof(address)); diff --git a/vdagentd.c b/vdagentd.c index b3c1ef3..47ec963 100644 --- a/vdagentd.c +++ b/vdagentd.c @@ -688,6 +688,8 @@ int main(int argc, char *argv[]) vdagent_virtio_port_destroy(&virtio_port); console_kit_destroy(console_kit); udscs_destroy_server(server); + if (unlink(VDAGENTD_SOCKET) != 0) + fprintf(logfile, "unlink %s: %s\n", VDAGENTD_SOCKET, strerror(errno)); fprintf(logfile, "vdagentd quiting, returning status %d\n", retval); if (logfile != stderr) fclose(logfile); -- cgit v1.2.3