From: Jon Griffiths Date: Tue, 23 Feb 2016 07:16:04 +0000 (-0500) Subject: credential-cache--daemon: change to the socket dir on startup X-Git-Tag: v2.8.0-rc0~15^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6e6144905188a76ef75c5418bd48c333adeebdcd;p=git credential-cache--daemon: change to the socket dir on startup Changing to the socket path stops the daemon holding open the directory the user was in when it was started, preventing umount from working. We're already holding open a socket in that directory, so there's no downside. Thanks-to: Jeff King Signed-off-by: Jon Griffiths Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- diff --git a/credential-cache--daemon.c b/credential-cache--daemon.c index fe3779472c..6b00ee0ee6 100644 --- a/credential-cache--daemon.c +++ b/credential-cache--daemon.c @@ -236,6 +236,15 @@ static void init_socket_directory(const char *path) if (mkdir(dir, 0700) < 0) die_errno("unable to mkdir '%s'", dir); } + + if (chdir(dir)) + /* + * We don't actually care what our cwd is; we chdir here just to + * be a friendly daemon and avoid tying up our original cwd. + * If this fails, it's OK to just continue without that benefit. + */ + ; + free(path_copy); }