From 8271f58d5122e2c8a9a68653767d6ca50692040c Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Wed, 3 Jan 2007 00:28:02 +0100 Subject: [PATCH] more: fix file descriptor leak When you view a file with the more command and run a shell, the file descriptor for reading the file is leaked to that process. To test, more any file. Then do !/bin/sh. At the prompt do "ls -l /proc/$$/fd" and you'll see the leaked fd. From: Steve Grubb Signed-off-by: Karel Zak --- text-utils/more.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/text-utils/more.c b/text-utils/more.c index 2b4fceb9..72f2832a 100644 --- a/text-utils/more.c +++ b/text-utils/more.c @@ -47,6 +47,7 @@ #include #include #include +#include #include #include #include @@ -478,6 +479,7 @@ checkf (fs, clearfirst) } if (magic(f, fs)) return((FILE *)NULL); + fcntl(fileno(f), F_SETFD, FD_CLOEXEC ); c = Getc(f); *clearfirst = (c == '\f'); Ungetc (c, f); -- 2.39.5