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
2026-04-29 20:10:02 +01:00

Introduction

pv ("Pipe Viewer") is a terminal-based tool for monitoring the progress of data through a pipeline and modifying its flow.

When used just like "cat", pv displays how quickly data is being transferred, how long it has taken, how near to completion it is, and an estimate of how long it will be until completion. Data flow rate, error handling strategy, buffer size, and cache interaction can all be adjusted.

With the "--cursor" option, several pv instances can work together, showing transfer progress at different points in the same pipeline.

In "--watchfd" mode, pv will inspect another process and show its progress through the files it has open.

In "--monitor" mode, pv will run a command and display the progress of data through both its standard input and its standard output.

Documentation

A manual page is included in this distribution ("man pv"). Before installation, it is in "docs/pv.1".

Changes are listed in "docs/NEWS.md".

Developers and translators, please see "docs/DEVELOPERS.md".

Translators can use the Weblate instance hosted by Codeberg: https://translate.codeberg.org/engage/pv/

Translation status

If you don't see your language listed, raise an issue on the issue tracker (or just email the maintainer) asking for it to be added.

Installation

See "docs/INSTALL" for more about the configure script.

The typical process for a system-wide install is:

sh ./configure --prefix=/usr
make
sudo make install

This requires the build toolchain ("sudo apt install build-essential" on Debian or Ubuntu systems).

If this is not a packaged release, the configure script is not included. It is generated with the GNU build system tools (autoconf, aclocal, autopoint, automake); gettext is also needed. On Debian or Ubuntu, run "sudo apt install automake autopoint gettext". Once those tools are in place, call "autoreconf -is" to generate the configure script, and run it as described above.

Copyright, bug reporting, and acknowledgements

See "docs/ACKNOWLEDGEMENTS.md" for a list of contributors.

Copyright (C) 2002-2008, 2010, 2012-2015, 2017, 2021, 2023-2026 Andrew Wood.

License GPLv3+: GNU GPL version 3 or later https://www.gnu.org/licenses/gpl-3.0.html.

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License, version 3, in "docs/COPYING". If not, see https://www.gnu.org/licenses/gpl-3.0.html.

Please report bugs or request features via the issue tracker linked from the home page.

The pv home page is at:

https://ivarch.com/p/pv

The latest version can always be found here.


S
Description
No description provided
Readme
2.7 MiB
Languages
C 85.3%
Shell 12.8%
M4 1%
Makefile 0.9%