Hello community,

here is the log from the commit of package pv for openSUSE:Factory checked in 
at 2017-08-08 11:59:49
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/pv (Old)
 and      /work/SRC/openSUSE:Factory/.pv.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "pv"

Tue Aug  8 11:59:49 2017 rev:15 rq:515101 version:1.6.6

Changes:
--------
--- /work/SRC/openSUSE:Factory/pv/pv.changes    2015-03-28 18:39:00.000000000 
+0100
+++ /work/SRC/openSUSE:Factory/.pv.new/pv.changes       2017-08-08 
11:59:54.710342859 +0200
@@ -1,0 +2,10 @@
+Mon Aug  7 23:34:32 UTC 2017 - jeng...@inai.de
+
+- Update to new upstream release 1.6.6
+  * Fix target buffer size (-B) being ignored
+  * Cap read/write sizes, and check elapsed time during read/write
+    cycle to avoid display hangs with large buffers or slow media.
+  * Report error in "-d" if process fd directory is unreadable, or
+    if process disappears before we start the main loop.
+
+-------------------------------------------------------------------

Old:
----
  pv-1.6.0.tar.bz2
  pv-1.6.0.tar.bz2.txt

New:
----
  pv-1.6.6.tar.bz2
  pv-1.6.6.tar.bz2.txt

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ pv.spec ++++++
--- /var/tmp/diff_new_pack.mgKaqN/_old  2017-08-08 11:59:56.354111344 +0200
+++ /var/tmp/diff_new_pack.mgKaqN/_new  2017-08-08 11:59:56.374108527 +0200
@@ -1,7 +1,7 @@
 #
 # spec file for package pv
 #
-# Copyright (c) 2015 SUSE LINUX GmbH, Nuernberg, Germany.
+# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany.
 #
 # All modifications and additions to the file contributed by third parties
 # remain the property of their copyright owners, unless otherwise agreed
@@ -17,7 +17,7 @@
 
 
 Name:           pv
-Version:        1.6.0
+Version:        1.6.6
 Release:        0
 Summary:        PipeViewer - Monitor the Progress of Data through Pipes
 License:        Artistic-2.0
@@ -52,23 +52,19 @@
 %setup -q
 
 %build
-%configure \
-       --enable-lfs \
-       --enable-nls \
-       --disable-debugging
-
+%configure --enable-lfs --enable-nls --disable-debugging
 make %{?_smp_mflags}
 
 %install
-make install DESTDIR="%buildroot"
-%find_lang "%{name}"
+%make_install
+%find_lang %name
 
 %check
 make test
 
 %files -f %name.lang
 %defattr(-,root,root)
-%doc README doc/COPYING doc/NEWS doc/TODO
+%doc README doc/COPYING doc/NEWS
 %_bindir/pv
 %doc %_mandir/man1/pv.1%ext_man
 

++++++ pv-1.6.0.tar.bz2 -> pv-1.6.6.tar.bz2 ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pv-1.6.0/README new/pv-1.6.6/README
--- old/pv-1.6.0/README 2015-03-15 01:29:51.000000000 +0100
+++ new/pv-1.6.6/README 2017-06-24 00:10:40.000000000 +0200
@@ -191,6 +191,7 @@
   Jacek Wielemborek <http://deetah.jogger.pl/kategorie/english>
     - implemented fdwatch in Python, suggested PV port
     - reported bug with "-l" and ETA / size
+    - suggested common switches
 
   Kim Krecht
     - suggested buffer fill status and last bytes output display options
@@ -224,4 +225,7 @@
   Erkki Seppälä <http://www.inside.org/~flux/>
     - provided patch implementing "-I"
 
+  Eric A. Borisch
+    - provided details of compatibility fix for "%Lu" in watchpid code
+
 -----------------------------------------------------------------------------
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pv-1.6.0/autoconf/make/filelist.mk~ 
new/pv-1.6.6/autoconf/make/filelist.mk~
--- old/pv-1.6.0/autoconf/make/filelist.mk~     2015-03-15 01:38:16.000000000 
+0100
+++ new/pv-1.6.6/autoconf/make/filelist.mk~     2017-06-30 23:23:38.000000000 
+0200
@@ -1,6 +1,6 @@
 # Automatically generated file listings
 #
-# Creation time: Sun Mar 15 00:38:16 GMT 2015
+# Creation time: Fri Jun 30 22:23:37 BST 2017
 
 allsrc = src/library/getopt.c \
 src/library/gettext.c \
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pv-1.6.0/autoconf/make/modules.mk~ 
new/pv-1.6.6/autoconf/make/modules.mk~
--- old/pv-1.6.0/autoconf/make/modules.mk~      2015-03-15 01:38:16.000000000 
+0100
+++ new/pv-1.6.6/autoconf/make/modules.mk~      2017-06-30 23:23:38.000000000 
+0200
@@ -1,6 +1,6 @@
 # Automatically generated module linking rules
 #
-# Creation time: Sun Mar 15 00:38:16 GMT 2015
+# Creation time: Fri Jun 30 22:23:37 BST 2017
 
 src/library.o:  src/library/getopt.o src/library/gettext.o
        $(LD) $(LDFLAGS) -o $@  src/library/getopt.o src/library/gettext.o
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pv-1.6.0/doc/NEWS new/pv-1.6.6/doc/NEWS
--- old/pv-1.6.0/doc/NEWS       2015-03-15 01:34:31.000000000 +0100
+++ new/pv-1.6.6/doc/NEWS       2017-06-30 23:18:33.000000000 +0200
@@ -1,3 +1,17 @@
+1.6.6 - 30 June 2017
+  - (r161) use %llu instead of %Lu for better compatibility (Eric A. Borisch)
+  - (r162) (#1532) fix target buffer size (-B) being ignored (AndCycle, Ilya
+    Basin, Antoine Beaupré)
+  - (r164) cap read/write sizes, and check elapsed time during read/write
+    cycles, to avoid display hangs with large buffers or slow media; also
+    remove select() call from repeated_write function as it slows the
+    transfer down and the wrapping alarm() means it is unnecessary
+  - (r169) (#1477) use alternate form for transfer counter, such that 13GB
+    is shown as 13.0GB so it's the same width as 13.1GB (André Stapf)
+  - (r171) cleanup: units corrections in man page, of the form kb -> KiB
+  - (r175) report error in "-d" if process fd directory is unreadable, or if
+    process disappears before we start the main loop (Jacek Wielemborek)
+
 1.6.0 - 15 March 2015
   - fix lstat64 support when unavailable - separate patches supplied by
     Ganael Laplanche and Peter Korsgaard
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pv-1.6.0/doc/TODO new/pv-1.6.6/doc/TODO
--- old/pv-1.6.0/doc/TODO       2015-03-15 01:29:19.000000000 +0100
+++ new/pv-1.6.6/doc/TODO       2017-06-24 00:14:13.000000000 +0200
@@ -1,21 +1,34 @@
 Things still to do:
 
-  - (#1505) option to switch rate to per minute if really slow
-  - (#1477) make 13GB be shown as 13.0GB so it's the same width as 13.1GB
+  - allow -E to take a block size argument so errors cause a skip to the
+    next block (Anthony DeRobertis)
+  - (#1559) momentary ETA option (Luc Gommans)
+  - (#1556) correct German translations (Richard Fonfara)
+  - (#1557) use clock_gettime() in ETA calculation (Mateju Miroslav)
+  - (#1561) show days in same format in ETA as in elapsed time
+  - (#1562) allow -r with -l and -n to output lines/sec (Roland Kletzing)
+  - (#1563) make -B imply -C (Johannes Gerer)
+  - document zsh <() incompatibility (frede...@ofb.net - Frederik Eaton)
+  - do not check terminal in -q/-n mode (zsh <(pv -n) fails)
+  - if -w/-H was specified, ignore SIGWINCH
+  - option to enable O_DIRECT (Romain Kang, Jacek Wielemborek)
+  - use posix_fadvise() like cat(1) does (Jacek Wielemborek)
   - (#1508) add watchfd tests
+  - (#1534) allow multiple -d options
+  - (#1533) one-shot option (Jacek Wielemborek)
+  - (#1505) option to switch rate to per minute if really slow
   - (#1510) option "--progress-from FILE", read last number and use it as 
bytes read:
     pv --progress-from <( while sleep 1; do du -sb somedir; done ) -s 123g
     (Jacek Wielemborek)
   - (#1476) (Debian #507682) adjustable averaging window for rate display
-  - (#1293) check transfer buffer usage on large memory systems
   - (#1286) option for process title (Martin Sarsale) as "pv - name:FooProcess 
-xyz - transferred: 1.3GB - 500KB/s - running: 10:15:30s"
   - (#1290) look at effect of O_SYNC or fsync on performance
   - (#1281) option (-x?) to use xterm title line for status (Joachim Haga)
   - (#1287) if the first pv exits, should the second become IPC leader?
+  - (#1560) use Unicode for more granular progress bar (Alexander Petrossian)
 
   - add development support for http://clang-analyzer.llvm.org/
   - stats for avg/min/max/stddev throughput (Venky.N.Iyer)
-  - option to enable O_DIRECT (Romain Kang)
   - pv-ify a command line (Will Entriken) - "pv FOO | BAR | BAZ"
   - get more translations
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pv-1.6.0/doc/VERSION new/pv-1.6.6/doc/VERSION
--- old/pv-1.6.0/doc/VERSION    2015-03-15 01:35:25.000000000 +0100
+++ new/pv-1.6.6/doc/VERSION    2017-06-30 23:15:16.000000000 +0200
@@ -1 +1 @@
-1.6.0
+1.6.6
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pv-1.6.0/doc/lsm new/pv-1.6.6/doc/lsm
--- old/pv-1.6.0/doc/lsm        2015-03-15 01:38:45.000000000 +0100
+++ new/pv-1.6.6/doc/lsm        2017-06-30 23:24:36.000000000 +0200
@@ -1,7 +1,7 @@
 Begin3
 Title:         pv
-Version:       1.6.0
-Entered-date:  15MAR15
+Version:       1.6.6
+Entered-date:  30JUN17
 Description:   A tool for monitoring the progress of data through a
                pipeline.  It can be inserted into any normal pipeline
                between two processes to give a visual indication of how
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pv-1.6.0/doc/lsm.in new/pv-1.6.6/doc/lsm.in
--- old/pv-1.6.0/doc/lsm.in     2015-03-15 01:35:31.000000000 +0100
+++ new/pv-1.6.6/doc/lsm.in     2017-06-30 23:16:34.000000000 +0200
@@ -1,7 +1,7 @@
 Begin3
 Title:         @PACKAGE@
 Version:       @VERSION@
-Entered-date:  15MAR15
+Entered-date:  30JUN17
 Description:   A tool for monitoring the progress of data through a
                pipeline.  It can be inserted into any normal pipeline
                between two processes to give a visual indication of how
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pv-1.6.0/doc/pv.spec new/pv-1.6.6/doc/pv.spec
--- old/pv-1.6.0/doc/pv.spec    2015-03-15 01:38:45.000000000 +0100
+++ new/pv-1.6.6/doc/pv.spec    2017-06-30 23:38:25.000000000 +0200
@@ -1,10 +1,10 @@
 Summary: Monitor the progress of data through a pipe
 Name: pv
-Version: 1.6.0
-Release: 1%{?dist}
+Version: 1.6.6
+Release: 1
 License: Artistic 2.0
 Group: Development/Tools
-Source: http://www.ivarch.com/programs/sources/pv-1.6.0.tar.gz
+Source: http://www.ivarch.com/programs/sources/pv-1.6.6.tar.gz
 Url: http://www.ivarch.com/programs/pv.shtml
 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
 BuildRequires: gettext
@@ -46,19 +46,33 @@
 %doc README doc/NEWS doc/TODO doc/COPYING
 
 %changelog
+* Fri Jun 30 2017 Andrew Wood <andrew.w...@ivarch.com> 1.6.6-1
+- (r161) use %llu instead of %Lu for better compatibility (Eric A. Borisch)
+- (r162) (#1532) fix target buffer size (-B) being ignored (AndCycle, Ilya
+- Basin, Antoine Beaupré)
+- (r164) cap read/write sizes, and check elapsed time during read/write
+- cycles, to avoid display hangs with large buffers or slow media; also
+- remove select() call from repeated_write function as it slows the
+- transfer down and the wrapping alarm() means it is unnecessary
+- (r169) (#1477) use alternate form for transfer counter, such that 13GB
+- is shown as 13.0GB so it's the same width as 13.1GB (André Stapf)
+- (r171) cleanup: units corrections in man page, of the form kb -> KiB
+- (r175) report error in "-d" if process fd directory is unreadable, or if
+- process disappears before we start the main loop (Jacek Wielemborek)
+
 * Sun Mar 15 2015 Andrew Wood <andrew.w...@ivarch.com> 1.6.0-1
 - fix lstat64 support when unavailable - separate patches supplied by Ganael
-  Laplanche and Peter Korsgaard
+- Laplanche and Peter Korsgaard
 - (#1506) new option "-D" / "--delay-start" to only show bar after N seconds
-  (Damon Harper)
+- (Damon Harper)
 - new option "--fineta" / "-I" to show ETA as time of day rather than time
-  remaining - patch supplied by Erkki Seppälä (r147)
+- remaining - patch supplied by Erkki Seppälä (r147)
 - (#1509) change ETA (--eta / -e) so that days are given if the hours
-  remaining are 24 or more (Jacek Wielemborek)
+- remaining are 24 or more (Jacek Wielemborek)
 - (#1499) repeat read and write attempts on partial buffer fill/empty to
-  work around post-signal transfer rate drop reported by Ralf Ramsauer
+- work around post-signal transfer rate drop reported by Ralf Ramsauer
 - (#1507) do not try to calculate total size in line mode, due to bug
-  reported by Jacek Wielemborek and Michiel Van Herwegen
+- reported by Jacek Wielemborek and Michiel Van Herwegen
 - cleanup: removed defunct RATS comments and unnecessary copyright notices
 - clean up displayed lines when using --watchfd PID, when PID exits
 - output errors on a new line to avoid overwriting transfer bar
@@ -110,12 +124,12 @@
 * Thu Dec  6 2012 Andrew Wood <andrew.w...@ivarch.com> 1.4.0-1
 - new option "--skip-errors" commissioned by Jim Salter
 - if stdout is a block device, and we don't know the total size, use the
-  size of that block device as the total (Peter Samuelson)
+- size of that block device as the total (Peter Samuelson)
 - new option "--stop-at-size" to stop after "--size" bytes
 - report correct filename on read errors
 - fix use-after-free bug in remote PID cleanup code
 - refactored large chunks of code to make it more readable and to replace
-  most static variables with a state structure
+- most static variables with a state structure
 
 * Mon Nov  5 2012 Andrew Wood <andrew.w...@ivarch.com> 1.3.9-1
 - allow "--format" parameters to be sent with "--remote"
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pv-1.6.0/doc/quickref.1.in 
new/pv-1.6.6/doc/quickref.1.in
--- old/pv-1.6.0/doc/quickref.1.in      2015-03-15 01:19:18.000000000 +0100
+++ new/pv-1.6.6/doc/quickref.1.in      2017-06-30 23:16:19.000000000 +0200
@@ -1,4 +1,4 @@
-.TH @UCPACKAGE@ 1 "March 2015" Linux "User Manuals"
+.TH @UCPACKAGE@ 1 "June 2017" Linux "User Manuals"
 .SH NAME
 @PACKAGE@ \- monitor the progress of data through a pipe
 .SH SYNOPSIS
@@ -303,16 +303,16 @@
 .B \-L RATE, \-\-rate-limit RATE
 Limit the transfer to a maximum of
 .B RATE
-bytes per second.  A suffix of "k", "m", "g", or "t" can be added to denote
-kilobytes (*1024), megabytes, and so on.
+bytes per second.  A suffix of "K", "M", "G", or "T" can be added to denote
+kibibytes (*1024), mebibytes, and so on.
 .TP
 .B \-B BYTES, \-\-buffer-size BYTES
 Use a transfer buffer size of
 .B BYTES
-bytes.  A suffix of "k", "m", "g", or "t" can be added to denote
-kilobytes (*1024), megabytes, and so on.  The default buffer size is the
-block size of the input file's filesystem multiplied by 32 (512kb max), or
-400kb if the block size cannot be determined.
+bytes.  A suffix of "K", "M", "G", or "T" can be added to denote
+kibibytes (*1024), mebibytes, and so on.  The default buffer size is the
+block size of the input file's filesystem multiplied by 32 (512KiB max), or
+400KiB if the block size cannot be determined.
 .TP
 .B \-C, \-\-no-splice
 Never use
@@ -391,10 +391,10 @@
 .B \-R PID
 will cause that instance to act as though it had been given
 this instance's command line instead.  For example, if
-.B @PACKAGE@ -L 123k
+.B @PACKAGE@ -L 123K
 is running with process ID 9876, then running
-.B @PACKAGE@ -R 9876 -L 321k
-will cause it to start using a rate limit of 321k instead of 123k.
+.B @PACKAGE@ -R 9876 -L 321K
+will cause it to start using a rate limit of 321KiB instead of 123KiB.
 Note that some options cannot be changed while running, such as
 .BR \-c ,
 .BR \-l ,
@@ -493,6 +493,27 @@
 .BR "\`%N %b %T %t %r %a %p %e'" .
 
 
+.SH COMMON SWITCHES
+Some suggested common switch combinations:
+
+.TP
+.B @PACKAGE@ -ptebar
+Show a progress bar, elapsed time, estimated completion time, byte counter,
+average rate, and current rate.
+.TP
+.B @PACKAGE@ -betlap
+Show a progress bar, elapsed time, estimated completion time, line counter,
+and average rate, counting lines instead of bytes.
+.TP
+.B @PACKAGE@ -t
+Show only the elapsed time - useful as a simple timer, e.g.
+.BR "sleep 10m | pv -t" .
+.TP
+.B @PACKAGE@ -pterb
+The default behaviour: progress bar, elapsed time, estimated completion
+time, current rate, and byte counter.
+
+
 .SH EXIT STATUS
 An exit status of 1 indicates a problem with the
 .B \-R
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pv-1.6.0/doc/spec.in new/pv-1.6.6/doc/spec.in
--- old/pv-1.6.0/doc/spec.in    2015-03-15 01:36:53.000000000 +0100
+++ new/pv-1.6.6/doc/spec.in    2017-06-30 23:18:25.000000000 +0200
@@ -46,19 +46,33 @@
 %doc README doc/NEWS doc/TODO doc/COPYING
 
 %changelog
+* Fri Jun 30 2017 Andrew Wood <andrew.w...@ivarch.com> 1.6.6-1
+- (r161) use %llu instead of %Lu for better compatibility (Eric A. Borisch)
+- (r162) (#1532) fix target buffer size (-B) being ignored (AndCycle, Ilya
+- Basin, Antoine Beaupré)
+- (r164) cap read/write sizes, and check elapsed time during read/write
+- cycles, to avoid display hangs with large buffers or slow media; also
+- remove select() call from repeated_write function as it slows the
+- transfer down and the wrapping alarm() means it is unnecessary
+- (r169) (#1477) use alternate form for transfer counter, such that 13GB
+- is shown as 13.0GB so it's the same width as 13.1GB (André Stapf)
+- (r171) cleanup: units corrections in man page, of the form kb -> KiB
+- (r175) report error in "-d" if process fd directory is unreadable, or if
+- process disappears before we start the main loop (Jacek Wielemborek)
+
 * Sun Mar 15 2015 Andrew Wood <andrew.w...@ivarch.com> 1.6.0-1
 - fix lstat64 support when unavailable - separate patches supplied by Ganael
-  Laplanche and Peter Korsgaard
+- Laplanche and Peter Korsgaard
 - (#1506) new option "-D" / "--delay-start" to only show bar after N seconds
-  (Damon Harper)
+- (Damon Harper)
 - new option "--fineta" / "-I" to show ETA as time of day rather than time
-  remaining - patch supplied by Erkki Seppälä (r147)
+- remaining - patch supplied by Erkki Seppälä (r147)
 - (#1509) change ETA (--eta / -e) so that days are given if the hours
-  remaining are 24 or more (Jacek Wielemborek)
+- remaining are 24 or more (Jacek Wielemborek)
 - (#1499) repeat read and write attempts on partial buffer fill/empty to
-  work around post-signal transfer rate drop reported by Ralf Ramsauer
+- work around post-signal transfer rate drop reported by Ralf Ramsauer
 - (#1507) do not try to calculate total size in line mode, due to bug
-  reported by Jacek Wielemborek and Michiel Van Herwegen
+- reported by Jacek Wielemborek and Michiel Van Herwegen
 - cleanup: removed defunct RATS comments and unnecessary copyright notices
 - clean up displayed lines when using --watchfd PID, when PID exits
 - output errors on a new line to avoid overwriting transfer bar
@@ -110,12 +124,12 @@
 * Thu Dec  6 2012 Andrew Wood <andrew.w...@ivarch.com> 1.4.0-1
 - new option "--skip-errors" commissioned by Jim Salter
 - if stdout is a block device, and we don't know the total size, use the
-  size of that block device as the total (Peter Samuelson)
+- size of that block device as the total (Peter Samuelson)
 - new option "--stop-at-size" to stop after "--size" bytes
 - report correct filename on read errors
 - fix use-after-free bug in remote PID cleanup code
 - refactored large chunks of code to make it more readable and to replace
-  most static variables with a state structure
+- most static variables with a state structure
 
 * Mon Nov  5 2012 Andrew Wood <andrew.w...@ivarch.com> 1.3.9-1
 - allow "--format" parameters to be sent with "--remote"
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pv-1.6.0/src/include/pv-internal.h 
new/pv-1.6.6/src/include/pv-internal.h
--- old/pv-1.6.0/src/include/pv-internal.h      2015-03-15 01:18:03.000000000 
+0100
+++ new/pv-1.6.6/src/include/pv-internal.h      2015-10-11 00:53:50.000000000 
+0200
@@ -37,6 +37,10 @@
 #define REMOTE_INTERVAL                100000   /* usec between checks for -R 
*/
 #define BUFFER_SIZE            409600   /* default transfer buffer size */
 #define BUFFER_SIZE_MAX                524288   /* max auto transfer buffer 
size */
+#define MAX_READ_AT_ONCE       524288   /* max to read() in one go */
+#define MAX_WRITE_AT_ONCE      524288   /* max to write() in one go */
+#define TRANSFER_READ_TIMEOUT  90000    /* usec to time reads out at */
+#define TRANSFER_WRITE_TIMEOUT 900000   /* usec to time writes out at */
 
 #define MAXIMISE_BUFFER_FILL   1
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pv-1.6.0/src/main/debug.c 
new/pv-1.6.6/src/main/debug.c
--- old/pv-1.6.0/src/main/debug.c       2015-03-15 01:37:18.000000000 +0100
+++ new/pv-1.6.6/src/main/debug.c       2017-06-30 23:21:49.000000000 +0200
@@ -31,14 +31,14 @@
        struct tm *tm;
        char tbuf[128];
 
-       if (tried_open == 0) {
+       if (0 == tried_open) {
                debugfile = getenv("DEBUG");
-               if (debugfile != NULL)
+               if (NULL != debugfile)
                        debugfptr = fopen(debugfile, "a");
                tried_open = 1;
        }
 
-       if (debugfptr == NULL)
+       if (NULL == debugfptr)
                return;
 
        time(&t);
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pv-1.6.0/src/nls/de.po new/pv-1.6.6/src/nls/de.po
--- old/pv-1.6.0/src/nls/de.po  2015-03-15 01:38:51.000000000 +0100
+++ new/pv-1.6.6/src/nls/de.po  2017-06-30 23:38:34.000000000 +0200
@@ -1,7 +1,7 @@
 msgid ""
 msgstr ""
 "Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2015-03-15 00:37+0000\n"
+"POT-Creation-Date: 2017-06-30 22:21+0100\n"
 "Content-Type: text/plain; charset=iso-8859-15\n"
 "Date: 1999-06-01 15:18:29+0100\n"
 "From: Andrew Wood <ivarch@ubik>\n"
@@ -20,7 +20,7 @@
 "compat.c\n"
 
 #: src/pv/watchpid.c:51 src/pv/watchpid.c:66 src/pv/watchpid.c:76
-#: src/pv/watchpid.c:107 src/pv/loop.c:518
+#: src/pv/watchpid.c:107 src/pv/loop.c:519 src/pv/loop.c:580 src/pv/loop.c:632
 msgid "pid"
 msgstr ""
 
@@ -83,52 +83,52 @@
 msgid "yzafpnum KMGTPEZY"
 msgstr ""
 
-#: src/pv/display.c:531 src/pv/transfer.c:612
+#: src/pv/display.c:532 src/pv/transfer.c:679
 msgid "buffer allocation failed"
 msgstr "Puffer konnte nicht allokiert werden"
 
-#: src/pv/display.c:591 src/pv/transfer.c:391
+#: src/pv/display.c:592 src/pv/transfer.c:458
 msgid "B"
 msgstr "B"
 
-#: src/pv/display.c:627 src/pv/display.c:635
+#: src/pv/display.c:628 src/pv/display.c:636
 msgid "/s"
 msgstr ""
 
-#: src/pv/display.c:627 src/pv/display.c:635
+#: src/pv/display.c:628 src/pv/display.c:636
 msgid "B/s"
 msgstr ""
 
-#: src/pv/display.c:670 src/pv/display.c:675 src/pv/display.c:737
+#: src/pv/display.c:671 src/pv/display.c:676 src/pv/display.c:738
 msgid "ETA"
 msgstr "ETA"
 
-#: src/pv/transfer.c:274
+#: src/pv/transfer.c:341
 msgid "read failed"
 msgstr "read-Aufruf fehlgeschlagen"
 
-#: src/pv/transfer.c:292
+#: src/pv/transfer.c:359
 msgid "warning: read errors detected"
 msgstr ""
 
-#: src/pv/transfer.c:307
+#: src/pv/transfer.c:374
 msgid "file is not seekable"
 msgstr ""
 
-#: src/pv/transfer.c:370
+#: src/pv/transfer.c:437
 #, fuzzy
 msgid "failed to seek past error"
 msgstr "Dateiinformationen konnten nicht gelesen werden"
 
-#: src/pv/transfer.c:389
+#: src/pv/transfer.c:456
 msgid "skipped past read error"
 msgstr ""
 
-#: src/pv/transfer.c:564
+#: src/pv/transfer.c:631
 msgid "write failed"
 msgstr "write-Aufruf fehlgeschlagen"
 
-#: src/pv/transfer.c:703
+#: src/pv/transfer.c:770
 msgid "select call failed"
 msgstr "select-Aufruf fehlgeschlagen"
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pv-1.6.0/src/nls/fr.po new/pv-1.6.6/src/nls/fr.po
--- old/pv-1.6.0/src/nls/fr.po  2015-03-15 01:38:51.000000000 +0100
+++ new/pv-1.6.6/src/nls/fr.po  2017-06-30 23:38:34.000000000 +0200
@@ -1,7 +1,7 @@
 msgid ""
 msgstr ""
 "Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2015-03-15 00:37+0000\n"
+"POT-Creation-Date: 2017-06-30 22:21+0100\n"
 "Content-Type: text/plain; charset=ISO-8859-15\n"
 "Date: 1999-06-01 15:18:29+0100\n"
 "From: Andrew Wood <ivarch@ubik>\n"
@@ -20,7 +20,7 @@
 "compat.c\n"
 
 #: src/pv/watchpid.c:51 src/pv/watchpid.c:66 src/pv/watchpid.c:76
-#: src/pv/watchpid.c:107 src/pv/loop.c:518
+#: src/pv/watchpid.c:107 src/pv/loop.c:519 src/pv/loop.c:580 src/pv/loop.c:632
 msgid "pid"
 msgstr ""
 
@@ -83,53 +83,53 @@
 msgid "yzafpnum KMGTPEZY"
 msgstr ""
 
-#: src/pv/display.c:531 src/pv/transfer.c:612
+#: src/pv/display.c:532 src/pv/transfer.c:679
 msgid "buffer allocation failed"
 msgstr "l'allocation de m�moire tampon a �chou�"
 
-#: src/pv/display.c:591 src/pv/transfer.c:391
+#: src/pv/display.c:592 src/pv/transfer.c:458
 msgid "B"
 msgstr "O"
 
-#: src/pv/display.c:627 src/pv/display.c:635
+#: src/pv/display.c:628 src/pv/display.c:636
 msgid "/s"
 msgstr "/s"
 
-#: src/pv/display.c:627 src/pv/display.c:635
+#: src/pv/display.c:628 src/pv/display.c:636
 #, fuzzy
 msgid "B/s"
 msgstr "O/s"
 
-#: src/pv/display.c:670 src/pv/display.c:675 src/pv/display.c:737
+#: src/pv/display.c:671 src/pv/display.c:676 src/pv/display.c:738
 msgid "ETA"
 msgstr "ETA"
 
-#: src/pv/transfer.c:274
+#: src/pv/transfer.c:341
 msgid "read failed"
 msgstr "la lecture a �chou�"
 
-#: src/pv/transfer.c:292
+#: src/pv/transfer.c:359
 msgid "warning: read errors detected"
 msgstr ""
 
-#: src/pv/transfer.c:307
+#: src/pv/transfer.c:374
 msgid "file is not seekable"
 msgstr ""
 
-#: src/pv/transfer.c:370
+#: src/pv/transfer.c:437
 #, fuzzy
 msgid "failed to seek past error"
 msgstr "�chec � statuer sur le fichier"
 
-#: src/pv/transfer.c:389
+#: src/pv/transfer.c:456
 msgid "skipped past read error"
 msgstr ""
 
-#: src/pv/transfer.c:564
+#: src/pv/transfer.c:631
 msgid "write failed"
 msgstr "l'�criture a �chou�"
 
-#: src/pv/transfer.c:703
+#: src/pv/transfer.c:770
 msgid "select call failed"
 msgstr "appel de s�lection a �chou�"
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pv-1.6.0/src/nls/pl.po new/pv-1.6.6/src/nls/pl.po
--- old/pv-1.6.0/src/nls/pl.po  2015-03-15 01:38:51.000000000 +0100
+++ new/pv-1.6.6/src/nls/pl.po  2017-06-30 23:38:35.000000000 +0200
@@ -6,7 +6,7 @@
 msgstr ""
 "Project-Id-Version: PACKAGE VERSION\n"
 "Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2015-03-15 00:37+0000\n"
+"POT-Creation-Date: 2017-06-30 22:21+0100\n"
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
 "Language-Team: LANGUAGE <l...@li.org>\n"
@@ -15,7 +15,7 @@
 "Content-Transfer-Encoding: 8bit\n"
 
 #: src/pv/watchpid.c:51 src/pv/watchpid.c:66 src/pv/watchpid.c:76
-#: src/pv/watchpid.c:107 src/pv/loop.c:518
+#: src/pv/watchpid.c:107 src/pv/loop.c:519 src/pv/loop.c:580 src/pv/loop.c:632
 msgid "pid"
 msgstr ""
 
@@ -80,52 +80,52 @@
 msgid "yzafpnum KMGTPEZY"
 msgstr ""
 
-#: src/pv/display.c:531 src/pv/transfer.c:612
+#: src/pv/display.c:532 src/pv/transfer.c:679
 msgid "buffer allocation failed"
 msgstr "nie uda�o si� zaalokowa� bufora"
 
-#: src/pv/display.c:591 src/pv/transfer.c:391
+#: src/pv/display.c:592 src/pv/transfer.c:458
 msgid "B"
 msgstr "B"
 
-#: src/pv/display.c:627 src/pv/display.c:635
+#: src/pv/display.c:628 src/pv/display.c:636
 msgid "/s"
 msgstr "/s"
 
-#: src/pv/display.c:627 src/pv/display.c:635
+#: src/pv/display.c:628 src/pv/display.c:636
 msgid "B/s"
 msgstr "B/s"
 
-#: src/pv/display.c:670 src/pv/display.c:675 src/pv/display.c:737
+#: src/pv/display.c:671 src/pv/display.c:676 src/pv/display.c:738
 msgid "ETA"
 msgstr "ETA"
 
-#: src/pv/transfer.c:274
+#: src/pv/transfer.c:341
 msgid "read failed"
 msgstr "b��d odczytu"
 
-#: src/pv/transfer.c:292
+#: src/pv/transfer.c:359
 msgid "warning: read errors detected"
 msgstr ""
 
-#: src/pv/transfer.c:307
+#: src/pv/transfer.c:374
 msgid "file is not seekable"
 msgstr ""
 
-#: src/pv/transfer.c:370
+#: src/pv/transfer.c:437
 #, fuzzy
 msgid "failed to seek past error"
 msgstr "nie uda�o si� wykona� operacji stat na pliku"
 
-#: src/pv/transfer.c:389
+#: src/pv/transfer.c:456
 msgid "skipped past read error"
 msgstr ""
 
-#: src/pv/transfer.c:564
+#: src/pv/transfer.c:631
 msgid "write failed"
 msgstr "b��d zapisu"
 
-#: src/pv/transfer.c:703
+#: src/pv/transfer.c:770
 msgid "select call failed"
 msgstr "nie uda�o si� wywo�a� funkcji select"
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pv-1.6.0/src/nls/pt.po new/pv-1.6.6/src/nls/pt.po
--- old/pv-1.6.0/src/nls/pt.po  2015-03-15 01:38:51.000000000 +0100
+++ new/pv-1.6.6/src/nls/pt.po  2017-06-30 23:38:35.000000000 +0200
@@ -6,7 +6,7 @@
 msgstr ""
 "Project-Id-Version: PACKAGE VERSION\n"
 "Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2015-03-15 00:37+0000\n"
+"POT-Creation-Date: 2017-06-30 22:21+0100\n"
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
 "Language-Team: LANGUAGE <l...@li.org>\n"
@@ -15,7 +15,7 @@
 "Content-Transfer-Encoding: 8bit\n"
 
 #: src/pv/watchpid.c:51 src/pv/watchpid.c:66 src/pv/watchpid.c:76
-#: src/pv/watchpid.c:107 src/pv/loop.c:518
+#: src/pv/watchpid.c:107 src/pv/loop.c:519 src/pv/loop.c:580 src/pv/loop.c:632
 msgid "pid"
 msgstr ""
 
@@ -78,52 +78,52 @@
 msgid "yzafpnum KMGTPEZY"
 msgstr ""
 
-#: src/pv/display.c:531 src/pv/transfer.c:612
+#: src/pv/display.c:532 src/pv/transfer.c:679
 msgid "buffer allocation failed"
 msgstr "erro alocando o buffer"
 
-#: src/pv/display.c:591 src/pv/transfer.c:391
+#: src/pv/display.c:592 src/pv/transfer.c:458
 msgid "B"
 msgstr ""
 
-#: src/pv/display.c:627 src/pv/display.c:635
+#: src/pv/display.c:628 src/pv/display.c:636
 msgid "/s"
 msgstr ""
 
-#: src/pv/display.c:627 src/pv/display.c:635
+#: src/pv/display.c:628 src/pv/display.c:636
 msgid "B/s"
 msgstr "B/s"
 
-#: src/pv/display.c:670 src/pv/display.c:675 src/pv/display.c:737
+#: src/pv/display.c:671 src/pv/display.c:676 src/pv/display.c:738
 msgid "ETA"
 msgstr "ETA"
 
-#: src/pv/transfer.c:274
+#: src/pv/transfer.c:341
 msgid "read failed"
 msgstr "erro de leitura"
 
-#: src/pv/transfer.c:292
+#: src/pv/transfer.c:359
 msgid "warning: read errors detected"
 msgstr ""
 
-#: src/pv/transfer.c:307
+#: src/pv/transfer.c:374
 msgid "file is not seekable"
 msgstr ""
 
-#: src/pv/transfer.c:370
+#: src/pv/transfer.c:437
 #, fuzzy
 msgid "failed to seek past error"
 msgstr "erro obtendo informa��es do arquivo"
 
-#: src/pv/transfer.c:389
+#: src/pv/transfer.c:456
 msgid "skipped past read error"
 msgstr ""
 
-#: src/pv/transfer.c:564
+#: src/pv/transfer.c:631
 msgid "write failed"
 msgstr "erro de grava��o"
 
-#: src/pv/transfer.c:703
+#: src/pv/transfer.c:770
 msgid "select call failed"
 msgstr "erro na chamada da fun��o select"
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pv-1.6.0/src/nls/pv.pot new/pv-1.6.6/src/nls/pv.pot
--- old/pv-1.6.0/src/nls/pv.pot 2015-03-15 01:37:20.000000000 +0100
+++ new/pv-1.6.6/src/nls/pv.pot 2017-06-30 23:21:49.000000000 +0200
@@ -8,7 +8,7 @@
 msgstr ""
 "Project-Id-Version: PACKAGE VERSION\n"
 "Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2015-03-15 00:37+0000\n"
+"POT-Creation-Date: 2017-06-30 22:21+0100\n"
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
 "Language-Team: LANGUAGE <l...@li.org>\n"
@@ -17,7 +17,7 @@
 "Content-Transfer-Encoding: 8bit\n"
 
 #: src/pv/watchpid.c:51 src/pv/watchpid.c:66 src/pv/watchpid.c:76
-#: src/pv/watchpid.c:107 src/pv/loop.c:518
+#: src/pv/watchpid.c:107 src/pv/loop.c:519 src/pv/loop.c:580 src/pv/loop.c:632
 msgid "pid"
 msgstr ""
 
@@ -77,51 +77,51 @@
 msgid "yzafpnum KMGTPEZY"
 msgstr ""
 
-#: src/pv/display.c:531 src/pv/transfer.c:612
+#: src/pv/display.c:532 src/pv/transfer.c:679
 msgid "buffer allocation failed"
 msgstr ""
 
-#: src/pv/display.c:591 src/pv/transfer.c:391
+#: src/pv/display.c:592 src/pv/transfer.c:458
 msgid "B"
 msgstr ""
 
-#: src/pv/display.c:627 src/pv/display.c:635
+#: src/pv/display.c:628 src/pv/display.c:636
 msgid "/s"
 msgstr ""
 
-#: src/pv/display.c:627 src/pv/display.c:635
+#: src/pv/display.c:628 src/pv/display.c:636
 msgid "B/s"
 msgstr ""
 
-#: src/pv/display.c:670 src/pv/display.c:675 src/pv/display.c:737
+#: src/pv/display.c:671 src/pv/display.c:676 src/pv/display.c:738
 msgid "ETA"
 msgstr ""
 
-#: src/pv/transfer.c:274
+#: src/pv/transfer.c:341
 msgid "read failed"
 msgstr ""
 
-#: src/pv/transfer.c:292
+#: src/pv/transfer.c:359
 msgid "warning: read errors detected"
 msgstr ""
 
-#: src/pv/transfer.c:307
+#: src/pv/transfer.c:374
 msgid "file is not seekable"
 msgstr ""
 
-#: src/pv/transfer.c:370
+#: src/pv/transfer.c:437
 msgid "failed to seek past error"
 msgstr ""
 
-#: src/pv/transfer.c:389
+#: src/pv/transfer.c:456
 msgid "skipped past read error"
 msgstr ""
 
-#: src/pv/transfer.c:564
+#: src/pv/transfer.c:631
 msgid "write failed"
 msgstr ""
 
-#: src/pv/transfer.c:703
+#: src/pv/transfer.c:770
 msgid "select call failed"
 msgstr ""
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pv-1.6.0/src/pv/display.c 
new/pv-1.6.6/src/pv/display.c
--- old/pv-1.6.0/src/pv/display.c       2015-03-15 01:37:18.000000000 +0100
+++ new/pv-1.6.6/src/pv/display.c       2017-06-30 23:21:49.000000000 +0200
@@ -207,7 +207,8 @@
                 * write display_amount separately first.
                 */
                char str_disp[64];
-               sprintf(str_disp, "%4.3Lg", display_amount);
+               /* # to get 13.0GB instead of 13GB (#1477) */
+               sprintf(str_disp, "%#4.3Lg", display_amount);
                sprintf(sizestr_buffer, "%s%.2s%.16s",
                        str_disp, si_prefix, suffix);
        }
@@ -243,8 +244,8 @@
        }
 
        formatstr =
-           state->format_string ? state->format_string : state->
-           default_format;
+           state->format_string ? state->
+           format_string : state->default_format;
 
        state->components_used = 0;
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pv-1.6.0/src/pv/loop.c new/pv-1.6.6/src/pv/loop.c
--- old/pv-1.6.0/src/pv/loop.c  2015-03-15 01:37:18.000000000 +0100
+++ new/pv-1.6.6/src/pv/loop.c  2017-06-30 23:21:49.000000000 +0200
@@ -116,7 +116,7 @@
         * Set target buffer size if the initial file's block size can be
         * read and we weren't given a target buffer size.
         */
-       if (0 == fstat64(fd, &sb)) {
+       if ((0 == fstat64(fd, &sb)) && (0 == state->target_buffer_size)) {
                unsigned long long sz;
                sz = sb.st_blksize * 32;
                if (sz > BUFFER_SIZE_MAX)
@@ -508,6 +508,7 @@
        struct timeval next_update, cur_time, next_remotecheck;
        int idx;
        int prev_displayed_lines, blank_lines;
+       int first_pass = 1;
 
        /*
         * Make sure the process exists first, so we can give an error if
@@ -531,8 +532,8 @@
         * it's not present.
         */
        original_format_string =
-           state->format_string ? state->format_string : state->
-           default_format;
+           state->format_string ? state->
+           format_string : state->default_format;
        if (NULL == strstr(original_format_string, "%N")) {
                snprintf(new_format_string, sizeof(new_format_string) - 1,
                         "%%N %s", original_format_string);
@@ -573,8 +574,20 @@
 
                gettimeofday(&cur_time, NULL);
 
-               if (kill(state->watch_pid, 0) != 0)
+               if (kill(state->watch_pid, 0) != 0) {
+                       if (first_pass) {
+                               pv_error(state, "%s %u: %s",
+                                        _("pid"), state->watch_pid,
+                                        strerror(errno));
+                               state->exit_status |= 2;
+                               if (NULL != info_array)
+                                       free(info_array);
+                               if (NULL != state_array)
+                                       free(state_array);
+                               return 2;
+                       }
                        break;
+               }
 
                if ((cur_time.tv_sec < next_update.tv_sec)
                    || (cur_time.tv_sec == next_update.tv_sec
@@ -613,9 +626,22 @@
                                         state->watch_pid, &array_length,
                                         &info_array, &state_array,
                                         fd_to_idx);
-               if (rc != 0)
+               if (rc != 0) {
+                       if (first_pass) {
+                               pv_error(state, "%s %u: %s",
+                                        _("pid"), state->watch_pid,
+                                        strerror(errno));
+                               state->exit_status |= 2;
+                               if (NULL != info_array)
+                                       free(info_array);
+                               if (NULL != state_array)
+                                       free(state_array);
+                               return 2;
+                       }
                        break;
+               }
 
+               first_pass = 0;
                displayed_lines = 0;
 
                for (fd = 0; fd < FD_SETSIZE; fd++) {
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pv-1.6.0/src/pv/transfer.c 
new/pv-1.6.6/src/pv/transfer.c
--- old/pv-1.6.0/src/pv/transfer.c      2015-03-15 01:37:18.000000000 +0100
+++ new/pv-1.6.6/src/pv/transfer.c      2017-06-30 23:21:49.000000000 +0200
@@ -14,6 +14,7 @@
 #include <sys/stat.h>
 #include <fcntl.h>
 #include <signal.h>
+#include <sys/time.h>
 
 
 /*
@@ -23,17 +24,28 @@
  * Unlike read(), if we have read less than "count" bytes, we check to see
  * if there's any more to read, and keep trying, to make sure we fill the
  * buffer as full as we can.
+ *
+ * We stop retrying if the time elapsed since this function was entered
+ * reaches TRANSFER_READ_TIMEOUT microseconds.
  */
 static ssize_t pv__transfer_read_repeated(int fd, void *buf, size_t count)
 {
+       struct timeval start_time;
        ssize_t total_read;
 
+       gettimeofday(&start_time, NULL);
+
        total_read = 0;
 
        while (count > 0) {
                ssize_t nread;
+               struct timeval now;
+               long elapsed_usec;
 
-               nread = read(fd, buf, count);
+               nread =
+                   read(fd, buf,
+                        count >
+                        MAX_READ_AT_ONCE ? MAX_READ_AT_ONCE : count);
                if (nread < 0)
                        return nread;
 
@@ -44,6 +56,17 @@
                if (0 == nread)
                        return total_read;
 
+               gettimeofday(&now, NULL);
+               elapsed_usec =
+                   1000000 * (now.tv_sec - start_time.tv_sec) +
+                   (now.tv_usec - start_time.tv_usec);
+               if (elapsed_usec > TRANSFER_READ_TIMEOUT) {
+                       debug("%s %d: %s (%ld %s)", "fd", fd,
+                             "stopping read - timer expired",
+                             elapsed_usec, "usec elapsed");
+                       return total_read;
+               }
+
                if (count > 0) {
                        fd_set readfds;
                        struct timeval tv;
@@ -73,19 +96,44 @@
  * Unlike write(), if we have written less than "count" bytes, we check to
  * see if we can write any more, and keep trying, to make sure we empty the
  * buffer as much as we can.
+ *
+ * We stop retrying if the time elapsed since this function was entered
+ * reaches TRANSFER_WRITE_TIMEOUT microseconds.
  */
 static ssize_t pv__transfer_write_repeated(int fd, void *buf, size_t count)
 {
+       struct timeval start_time;
        ssize_t total_written;
 
+       gettimeofday(&start_time, NULL);
+
        total_written = 0;
 
        while (count > 0) {
                ssize_t nwritten;
-
-               nwritten = write(fd, buf, count);
-               if (nwritten < 0)
-                       return nwritten;
+               struct timeval now;
+               long elapsed_usec;
+               size_t asked_to_write;
+
+               asked_to_write = count >
+                   MAX_WRITE_AT_ONCE ? MAX_WRITE_AT_ONCE : count;
+
+               nwritten = write(fd, buf, asked_to_write);
+               if (nwritten < 0) {
+                       if ((EINTR == errno) || (EAGAIN == errno)) {
+                               /*
+                                * Interrupted by a signal - probably our
+                                * alarm() - so just return what we've
+                                * written so far.
+                                */
+                               return total_written;
+                       } else {
+                               /*
+                                * Legitimate error - return negative.
+                                */
+                               return nwritten;
+                       }
+               }
 
                total_written += nwritten;
                buf += nwritten;
@@ -94,6 +142,23 @@
                if (0 == nwritten)
                        return total_written;
 
+               gettimeofday(&now, NULL);
+               elapsed_usec =
+                   1000000 * (now.tv_sec - start_time.tv_sec) +
+                   (now.tv_usec - start_time.tv_usec);
+               if (elapsed_usec > TRANSFER_WRITE_TIMEOUT) {
+                       debug("%s %d: %s (%ld %s)", "fd", fd,
+                             "stopping write - timer expired",
+                             elapsed_usec, "usec elapsed");
+                       return total_written;
+               }
+
+               /*
+                * Running the select() here seems to make PV eat a lot of
+                * CPU in some cases, so instead we just go round the loop
+                * again and rely on our alarm() to interrupt us if we run
+                * out of time - also on our gettimeofday() check.
+                */
                if (count > 0) {
                        fd_set writefds;
                        struct timeval tv;
@@ -107,8 +172,10 @@
                              "trying another write after partial buffer flush",
                              nwritten, "written", count, "remaining");
 
+# if 0                                     /* disabled after 1.6.0 - see 
comment above */
                        if (select(fd + 1, NULL, &writefds, NULL, &tv) < 1)
                                break;
+# endif
                }
        }
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pv-1.6.0/src/pv/watchpid.c 
new/pv-1.6.6/src/pv/watchpid.c
--- old/pv-1.6.0/src/pv/watchpid.c      2015-03-15 01:37:18.000000000 +0100
+++ new/pv-1.6.6/src/pv/watchpid.c      2017-06-30 23:21:49.000000000 +0200
@@ -157,7 +157,7 @@
        if (NULL == fptr)
                return -1;
        position = -1;
-       fscanf(fptr, "pos: %Lu", &position);
+       fscanf(fptr, "pos: %llu", &position);
        fclose(fptr);
 
        return position;



Reply via email to