diff options
author | Hans de Goede <hdegoede@redhat.com> | 2010-11-01 12:25:16 +0100 |
---|---|---|
committer | Hans de Goede <hdegoede@redhat.com> | 2010-11-01 12:25:16 +0100 |
commit | ba324d0f1fdee3e5f24618b4d590011007d417a2 (patch) | |
tree | a46124f41138a22710a3a2a352f30c8fb0082f36 | |
parent | f05f0a5602cb386b905d3ffcddcb12bdf9a823e4 (diff) |
vdagentd: unlink socket on exit rather then startup
This makes sure that the daemon cannot be started twice.
-rw-r--r-- | udscs.c | 8 | ||||
-rw-r--r-- | vdagentd.c | 2 |
2 files changed, 2 insertions, 8 deletions
@@ -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)); @@ -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); |