ash: fix open fds leaking in redirects. Closes 9561
commit e19923f665
deleted clearredir()
call in shellexec():
ash: [REDIR] Remove redundant CLOEXEC calls
Upstream commit:
Now that we're marking file descriptors as CLOEXEC in savefd, we no longer
need to close them on exec or in setinputfd.
but it missed one place where we don't set CLOEXEC. Fixing this.
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
6
shell/hush_test/hush-redir/redir_leak.right
Normal file
6
shell/hush_test/hush-redir/redir_leak.right
Normal file
@@ -0,0 +1,6 @@
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
10
shell/hush_test/hush-redir/redir_leak.tests
Executable file
10
shell/hush_test/hush-redir/redir_leak.tests
Executable file
@@ -0,0 +1,10 @@
|
||||
# Each of these should show only four lines:
|
||||
# fds 0,1,2 are stdio; fd 3 is open by opendir() in ls.
|
||||
# This test detects bugs where redirects leave stray open fds.
|
||||
|
||||
ls -1 /proc/self/fd | wc -l
|
||||
ls -1 /proc/self/fd >/proc/self/fd/1 | wc -l
|
||||
ls -1 /proc/self/fd >/proc/self/fd/1 2>&1 | wc -l
|
||||
echo "`ls -1 /proc/self/fd `" | wc -l
|
||||
echo "`ls -1 /proc/self/fd >/proc/self/fd/1 `" | wc -l
|
||||
echo "`ls -1 /proc/self/fd >/proc/self/fd/1 2>&1 `" | wc -l
|
Reference in New Issue
Block a user