mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-16 18:31:14 -03:00
Pipe fds to move to the "high range"
This concerns how fish prevents its own fds from interfering with user-defined fd redirections, like `echo hi >&5`. fish has historically done this by tracking all user defined redirections when running a job, and ensuring that pipes are not assigned the same fds. However this is annoying to pass around - it means that we have to thread user-defined redirections into pipe creation. Take a page from zsh and just ensure that all pipes we create have fds in the "high range," which here means at least 10. The primary way to do this is via the F_DUPFD_CLOEXEC syscall, which also sets CLOEXEC, so we aren't invoking additional syscalls in the common case. This will free us from having to track which fds are in user-defined redirections.
This commit is contained in:
@@ -968,7 +968,7 @@ bool exec_job(parser_t &parser, const shared_ptr<job_t> &j, const io_chain_t &bl
|
||||
autoclose_pipes_t proc_pipes;
|
||||
proc_pipes.read = std::move(pipe_next_read);
|
||||
if (!p->is_last_in_job) {
|
||||
auto pipes = make_autoclose_pipes(conflicts);
|
||||
auto pipes = make_autoclose_pipes();
|
||||
if (!pipes) {
|
||||
FLOGF(warning, PIPE_ERROR);
|
||||
wperror(L"pipe");
|
||||
|
||||
Reference in New Issue
Block a user