diff options
author | Herbert Xu <herbert@gondor.apana.org.au> | 2024-05-04 15:21:22 +0800 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2024-05-12 12:07:29 +0800 |
commit | ea5e24281aaaead307b08bd3f646a138c19ea6bc (patch) | |
tree | 3be980f9284355f88258aefc469b3d7fa7645c2f | |
parent | 257f6b36b8505dca9d073a2c5d4903c9c86faae9 (diff) | |
download | dash-master.tar.gz |
For a redirection like "> /dev/null" dupredirect will close the
newly opened file descriptor twice in a row because sh_dup2 also
closes the new file descriptor.
Remove the extra close in dupredirect.
Fixes: 509f5b0dcd71 ("redir: Use memfd_create instead of pipe")
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
-rw-r--r-- | src/redir.c | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/src/redir.c b/src/redir.c index bf5207d..2505d49 100644 --- a/src/redir.c +++ b/src/redir.c @@ -319,11 +319,9 @@ static void dupredirect(union node *redir, int f) sh_dup2(f, fd, -1); return; } - f = fd; + close(fd); } else sh_dup2(f, fd, f); - - close(f); } int sh_pipe(int pip[2], int memfd) |