# HG changeset patch # User Jun Wu # Date 2016-04-10 23:18:27 # Node ID 0d530299acf2f586f5e47b3fc5055908e2eeea0b # Parent f5764e177bbe0e3795412b5faf6621b433d762eb chg: use fsetcloexec instead of closing lockfd manually Since we have the fsetcloexec utility function, use it instead of closing lockfd manually. diff --git a/contrib/chg/chg.c b/contrib/chg/chg.c --- a/contrib/chg/chg.c +++ b/contrib/chg/chg.c @@ -178,6 +178,7 @@ static void lockcmdserver(struct cmdserv if (opts->lockfd == -1) abortmsgerrno("cannot create lock file %s", opts->lockfile); + fsetcloexec(opts->lockfd); } int r = flock(opts->lockfd, LOCK_EX); if (r == -1) @@ -309,8 +310,6 @@ static hgclient_t *connectcmdserver(stru if (pid < 0) abortmsg("failed to fork cmdserver process"); if (pid == 0) { - /* do not leak lockfd to hg */ - close(opts->lockfd); execcmdserver(opts); } else { hgc = retryconnectcmdserver(opts, pid);