mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-17 11:01:14 -03:00
io_buffer_t becomes io_bufferfill_t
This makes some significant architectual improvements to io_pipe_t and io_buffer_t. Prior to this fix, io_buffer_t subclassed io_pipe_t. io_buffer_t is now replaced with a class io_bufferfill_t, which does not subclass pipe. io_pipe_t no longer remembers both fds. Instead it has an autoclose_fd_t, so that the file descriptor ownership is clear.
This commit is contained in:
@@ -73,15 +73,17 @@ maybe_t<dup2_list_t> dup2_list_t::resolve_chain(const io_chain_t &io_chain) {
|
||||
break;
|
||||
}
|
||||
|
||||
case io_mode_t::buffer:
|
||||
case io_mode_t::pipe: {
|
||||
const io_pipe_t *io = static_cast<const io_pipe_t *>(io_ref.get());
|
||||
// If write_pipe_idx is 0, it means we're connecting to the read end (first pipe
|
||||
// fd). If it's 1, we're connecting to the write end (second pipe fd).
|
||||
unsigned int write_pipe_idx = (io->is_input ? 0 : 1);
|
||||
result.add_dup2(io->pipe_fd[write_pipe_idx], io->fd);
|
||||
if (io->pipe_fd[0] >= 0) result.add_close(io->pipe_fd[0]);
|
||||
if (io->pipe_fd[1] >= 0) result.add_close(io->pipe_fd[1]);
|
||||
result.add_dup2(io->pipe_fd(), io->fd);
|
||||
result.add_close(io->pipe_fd());
|
||||
break;
|
||||
}
|
||||
|
||||
case io_mode_t::bufferfill: {
|
||||
const io_bufferfill_t *io = static_cast<const io_bufferfill_t *>(io_ref.get());
|
||||
result.add_dup2(io->write_fd(), io->fd);
|
||||
result.add_close(io->write_fd());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user