Correctly cloexec file redirections

The IO cleanup left file redirections open in the child. For example,
/bin/cmd < file.txt would redirect stdin but also leave the file open.
Ensure these get closed properly.
This commit is contained in:
ridiculousfish
2019-12-13 16:16:19 -08:00
parent 1f83fb47ce
commit d6c71d77a9
4 changed files with 43 additions and 1 deletions

24
tests/checks/fds.fish Normal file
View File

@@ -0,0 +1,24 @@
# RUN: %fish -C "set helper %fish_test_helper" %s
# Check that we don't leave stray FDs.
$helper print_fds
# CHECK: 0 1 2
$helper print_fds 0>&-
# CHECK: 1 2
$helper print_fds 0>&- 2>&-
# CHECK: 1
false | $helper print_fds 0>&-
# CHECK: 0 1 2
$helper print_fds <(status current-filename)
# CHECK: 0 1 2
$helper print_fds <(status current-filename)
# CHECK: 0 1 2
$helper print_fds 3<(status current-filename)
# CHECK: 0 1 2 3