contrib/chg/chg.c
changeset 28852 7b5f5a1b4b41
parent 28851 584e0716c7af
child 28853 d11548b4ae45
--- a/contrib/chg/chg.c	Sun Apr 10 21:56:05 2016 +0100
+++ b/contrib/chg/chg.c	Sun Apr 10 23:56:00 2016 +0100
@@ -36,17 +36,23 @@
 	size_t argsize;
 	const char **args;
 	int lockfd;
+	int sockdirfd;
 };
 
 static void initcmdserveropts(struct cmdserveropts *opts) {
 	memset(opts, 0, sizeof(struct cmdserveropts));
 	opts->lockfd = -1;
+	opts->sockdirfd = AT_FDCWD;
 }
 
 static void freecmdserveropts(struct cmdserveropts *opts) {
 	free(opts->args);
 	opts->args = NULL;
 	opts->argsize = 0;
+	if (opts->sockdirfd != AT_FDCWD) {
+		close(opts->sockdirfd);
+		opts->sockdirfd = AT_FDCWD;
+	}
 }
 
 /*