When splice() is available but neither the input nor the output are pipes, splice the input through an intermediary pipe (#188).

This commit is contained in:
Andrew Wood
2026-05-03 01:12:33 +01:00
parent 17cbab3045
commit 21c8237a73
5 changed files with 173 additions and 10 deletions
+11
View File
@@ -160,6 +160,8 @@ struct pvstate_s {
bool terminal_supports_utf8; /* whether the terminal supports UTF-8 */
bool terminal_supports_colour; /* whether the terminal supports colour */
bool checked_colour_support; /* whether we have checked colour support yet */
bool current_input_is_pipe; /* whether the current input file is a pipe */
bool output_is_pipe; /* whether the output is a pipe */
} status;
/***************
@@ -456,6 +458,15 @@ struct pvstate_s {
int last_read_skip_fd;
/* read_error_warning_shown is defined below. */
#ifdef HAVE_SPLICE
/*
* File descriptors for an intermediate pipe, used when
* neither input nor output are pipes; the size of the pipe
* buffer; and how much input data is in the intermediate
* pipe waiting to be passed to the output.
*/
int intermediate_pipe[2];
int intermediate_pipe_buffer_size;
int intermediate_pipe_buffer_used;
/*
* These variables are used to keep track of whether
* splice() was used; splice_failed_fd is the file