summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--usr.bin/vi/common/exf.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/usr.bin/vi/common/exf.c b/usr.bin/vi/common/exf.c
index 574a16aab3b..dd0eba7fd87 100644
--- a/usr.bin/vi/common/exf.c
+++ b/usr.bin/vi/common/exf.c
@@ -1436,6 +1436,10 @@ file_lock(sp, name, fdp, fd, iswrite)
if (!O_ISSET(sp, O_LOCKFILES))
return (LOCK_SUCCESS);
+ /* Set close-on-exec flag so locks are not inherited by shell cmd. */
+ if (fcntl(fd, F_SETFD, 1) == -1)
+ msgq_str(sp, M_SYSERR, name, "%s");
+
#ifdef HAVE_LOCK_FLOCK /* Hurrah! We've got flock(2). */
/*
* !!!