Andrew Wood
e043efd259
Handle splice failures more robustly when the intermediate pipe is involved.
2026-05-23 00:32:50 +01:00
Andrew Wood
1f27ba3b35
Try to explain more clearly.
2026-05-20 22:58:53 +01:00
Andrew Wood
905e27ad47
Remove overly specific edge-case error messages, where just the filename and the system error would suffice; replace all the different types of memory allocation error with "memory allocation failure", since the action for the end-user is the same in all cases; and use the error messages "memory allocation failure", "interrupted by a signal", "error closing file", "input file is also the output", and "write error" since these are all used by either coreutils and grep, in similar contexts, so their translations can be copied.
2026-05-17 00:31:46 +01:00
Andrew Wood
b51afc07e2
Correct the --bar-style description to use the same placeholder as in the option spec.
2026-05-16 16:13:26 +01:00
Andrew Wood
1a00a7fdf5
Correct the off_t/size_t max_to_write overflow check.
2026-05-15 23:42:49 +01:00
Andrew Wood
d546e90a94
Break pv__transfer_read() into smaller functions to separate out the different parts, and improve the splice() handling when rate limiting and when EOF / Control-D is typed into stdin.
2026-05-15 23:23:24 +01:00
Andrew Wood
60203aabf5
Add retries on signal interrupt to the splicing into and out of the intermediate input pipe, and add a TODO marker highlighting a problem with the way splice() is currently handled.
2026-05-13 22:19:03 +01:00
Andrew Wood
d65dbd2f37
Make pv_format() static, as it is only used in one place (cppcheck recommendation).
2026-05-12 23:06:09 +01:00
Andrew Wood
65741d9b2e
Remove needless "continue" in the empty "for" loop (cppcheck recommendation).
2026-05-11 20:59:42 +01:00
Andrew Wood
4fbcfebc6c
Remove needless comparisons that would always be true here (cppcheck recommendation).
2026-05-11 20:56:10 +01:00
Andrew Wood
270bcb066e
Make pv_watchfd_info() and pv_reset_watchfd() static, as they are only used in one place (cppcheck recommendation).
2026-05-11 20:50:43 +01:00
Andrew Wood
229aadf194
Make the struct dirent a const (cppcheck recommendation).
2026-05-11 20:43:45 +01:00
Andrew Wood
61b412b0f1
Mark pointers to constant buffers as const (cppcheck recommendation).
2026-05-10 20:38:49 +01:00
Andrew Wood
6772d7e5a1
Read the EOF values in the debug statements by dereferencing the eof_in and eof_out pointers, not by using the pointers as a truth value.
2026-05-10 20:17:11 +01:00
Andrew Wood
f6b2196369
Reduce the scope of offset (cppcheck recommendation).
2026-05-10 20:05:42 +01:00
Andrew Wood
d2c183d234
Remove redundant assigment (cppcheck recommendation).
2026-05-10 19:55:02 +01:00
Andrew Wood
e09976042d
Reduce the scope of the first keyword_index (cppcheck recommendation), and in the formatter, guard against a size_t underflow by checking the write position each time it's used (implied by cppcheck).
2026-05-10 19:25:07 +01:00
Andrew Wood
7ddbc72525
Make the struct tm a const (cppcheck recommendation).
2026-05-10 19:19:30 +01:00
Andrew Wood
7c19f58e75
Mark pointers to constant buffers as const (cppcheck recommendation).
2026-05-10 19:18:01 +01:00
Andrew Wood
723d96b54b
Mark argument as pointer to const, since only the pointer changes (cppcheck recommendation).
2026-05-10 19:17:12 +01:00
Andrew Wood
6b5d217e22
Reduce the scope of end_idx (cppcheck recommendation).
2026-05-10 19:15:54 +01:00
Andrew Wood
d9eb83e1f5
Make the struct tm a const (cppcheck recommendation).
2026-05-10 19:15:17 +01:00
Andrew Wood
adf2767763
Additional commentary on total_written and rate limiting.
2026-05-09 20:24:49 +01:00
Andrew Wood
4fc5d10671
Remove spurious extra word.
2026-05-09 20:08:25 +01:00
Andrew Wood
6f9e73f058
Add more detailed comments about the rate limiter.
2026-05-09 20:04:02 +01:00
Andrew Wood
d381a1c714
Correct the rate limit burst cap so it won't prevent output when the rate is below 0.2, and handle the case where more than one rate limit interval has passed since the last calculation ( #193 ).
2026-05-09 00:37:29 +01:00
Andrew Wood
0a98062586
Define RATE_BURST_WINDOW as a floating point value since it's used in floating point calculations ( #193 ).
2026-05-09 00:35:19 +01:00
Andrew Wood
e7087b101d
Allow "-L 0" to be propagated with "-R" so that a remote process can have its rate limiting turned off as well as on; and update the manual to note this ( #193 ).
2026-05-08 21:07:29 +01:00
Andrew Wood
eae06cf3c0
Correct the remote setting of the rate limit so that -R without -L does not turn off the current rate limiting of the remote process ( #193 ).
2026-05-07 23:00:33 +01:00
Andrew Wood
0e7a77b42a
Allow the rate limit to be specified as a fractional number ( #193 ).
2026-05-06 23:24:51 +01:00
Andrew Wood
547efed258
Set the exit status to 8 when /dev/null is not usable and --discard is active ( #192 ).
2026-05-04 16:30:34 +01:00
Andrew Wood
cfe7b4e97a
Whitespace correction in comment.
2026-05-03 19:42:33 +01:00
Andrew Wood
10895792d2
When opening /dev/null internally, check that it really is a null device, and refuse to use it if not ( #192 ).
2026-05-03 19:37:27 +01:00
Andrew Wood
ae60fc0688
Move output_fd into HAVE_SPLICE.
2026-05-03 17:06:47 +01:00
Andrew Wood
11d727a88d
In discard mode, if splice() is available, open a file descriptor to /dev/null and splice the input to that, to improve performance ( #191 ).
2026-05-03 14:53:45 +01:00
Andrew Wood
b75ecd79d5
Add comments explaining the steps ( #188 ).
2026-05-03 13:42:27 +01:00
Andrew Wood
5fb7e49848
Start the intermediary pipe buffer size at 1MiB ( #188 ).
2026-05-03 13:41:52 +01:00
Andrew Wood
21c8237a73
When splice() is available but neither the input nor the output are pipes, splice the input through an intermediary pipe ( #188 ).
2026-05-03 01:12:33 +01:00
Andrew Wood
17cbab3045
Add an option "-J" / "--pipe-buffer-size" to set the size of the output pipe buffer when the output is a pipe, and when that option is not specified, automatically increase the output pipe buffer size to match that of the input, when the first input is also a pipe ( #188 ).
2026-05-02 16:42:35 +01:00
Andrew Wood
d421024fb8
Run through "make indent" for consistency, update message line numbers.
2026-05-01 19:47:10 +01:00
Wolfgang Hoschek
e7d188ac65
fix: avoid EOF hang on unread pipe output ( #189 )
...
At EOF, pv waits for bytes already written to an output pipe to be consumed before finishing. If the downstream reader exits without reading those bytes, the pipe can keep reporting unread data forever. Since pv has no more input, there is no later write that would fail with EPIPE and break the wait.
Detect this EOF drain-wait case with a non-blocking poll() on the output pipe. When the pipe reports that its readers are gone, mark the pipe closed and stop waiting for bytes that can no longer be consumed. While a reader is still present, keep the existing behaviour and continue waiting for the pipe buffer to drain.
Add regression coverage for both ways pv can reach this state: direct input that leaves unread output bytes behind, and a pipeline where the original producer fails but an intermediate filter such as gzip still emits a valid empty stream. The latter matters because pv can still have pending output at EOF even when the command at the start of the pipeline failed immediately.
Signed-off-by: Wolfgang Hoschek <wolfgang.hoschek@mac.com >
2026-04-30 04:47:09 -04:00
Andrew Wood
79a6420fea
Replace the fixed-sized buffer file_fdpath with a dynamically allocated equivalent.
2026-04-29 21:43:46 +01:00
Andrew Wood
a3f0caeab4
Record the received number before setting the exit trigger, so it will definitely be available for reporting ( #187 ).
2026-04-28 22:55:16 +01:00
Andrew Wood
478039f539
Report which signal triggered the exit ( #187 ).
2026-04-28 22:53:23 +01:00
Andrew Wood
2a25221eaf
Suppress the error message about a signal interrupt in cursor mode in all but the first instance in a pipeline ( #187 ).
2026-04-27 21:27:20 +01:00
Andrew Wood
c763f1fcaa
Write an error message if interrupted by a signal such as SIGINT ( #187 ).
2026-04-26 21:45:36 +01:00
Andrew Wood
8b4fa8ade7
Clear the terminal flag ECHOCTL before starting, and set it again at the end, similar to how TOSTOP is dealt with ( #187 ).
2026-04-26 20:01:22 +01:00
Andrew Wood
57f0b91d16
Adjust the watchfd changes for Apple builds.
2026-04-25 23:05:17 +01:00
Andrew Wood
2a31b73a32
Replace the fixed-sized buffers file_fdinfo and file_fdsymlink with dynamically allocated equivalents.
2026-04-25 22:04:38 +01:00
Andrew Wood
ee96f3f43b
Specify which watched PID had the problem.
2026-04-25 21:04:41 +01:00