Unlink the daemon socket in the shutdown callback, instead of right
before creating a new one. This makes sure we are unlinking the right
socket.
---
src/launch-direct.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/src/launch-direct.c b/src/launch-direct.c
index 1c805e3..b8e453d 100644
--- a/src/launch-direct.c
+++ b/src/launch-direct.c
@@ -296,7 +296,6 @@ launch_direct (guestfs_h *g, void *datav, const char *arg)
* for qemu to connect to.
*/
snprintf (data->guestfsd_sock, sizeof data->guestfsd_sock,
"%s/guestfsd.sock", g->tmpdir);
- unlink (data->guestfsd_sock);
daemon_accept_sock = socket (AF_UNIX, SOCK_STREAM|SOCK_CLOEXEC, 0);
if (daemon_accept_sock == -1) {
@@ -1510,6 +1509,11 @@ shutdown_direct (guestfs_h *g, void *datav, int check_for_errors)
data->pid = data->recoverypid = 0;
+ if (data->guestfsd_sock[0] != '\0') {
+ unlink (data->guestfsd_sock);
+ data->guestfsd_sock[0] = '\0';
+ }
+
free (data->qemu_help);
data->qemu_help = NULL;
free (data->qemu_version);
--
2.5.0