Download raw body.
pax: line-buffer file list output
ok guenther@
On Fri, May 10, 2024 at 11:44 AM Todd C. Miller <millert@openbsd.org> wrote:
> One thing that has bugged me for years is that pax/tar fully buffers
> the file list output when used in a pipeline. For example, given:
>
> $ tar cf - * | ssh otherhost "tar vxf -"
>
> the file list output will all be displayed at the end instead of
> as the files are written. If the list file handle is not stderr,
> making it line buffered fixes this.
>
> - todd
>
> Index: bin/pax/cpio.c
> ===================================================================
> RCS file: /cvs/src/bin/pax/cpio.c,v
> diff -u -p -u -r1.114 options.c
> --- bin/pax/options.c 17 Apr 2024 18:12:12 -0000 1.114
> +++ bin/pax/options.c 10 May 2024 18:38:02 -0000
> @@ -277,21 +277,20 @@ options(int argc, char **argv)
> if (strcmp(NM_TAR, argv0) == 0) {
> op_mode = OP_TAR;
> tar_options(argc, argv);
> - return;
> - }
> #ifndef NOCPIO
> - else if (strcmp(NM_CPIO, argv0) == 0) {
> + } else if (strcmp(NM_CPIO, argv0) == 0) {
> op_mode = OP_CPIO;
> cpio_options(argc, argv);
> - return;
> - }
> #endif /* !NOCPIO */
> - /*
> - * assume pax as the default
> - */
> - argv0 = NM_PAX;
> - op_mode = OP_PAX;
> - pax_options(argc, argv);
> + } else {
> + argv0 = NM_PAX;
> + op_mode = OP_PAX;
> + pax_options(argc, argv);
> + }
> +
> + /* Line-buffer the file list output as needed. */
> + if (listf != stderr)
> + setvbuf(listf, NULL, _IOLBF, 0);
> }
>
> /*
>
>
pax: line-buffer file list output