From 8758bb59215ff825bea976e3c426fda7b6459b48 Mon Sep 17 00:00:00 2001 From: millert Date: Fri, 10 May 2024 20:28:31 +0000 Subject: [PATCH] pax: make list file handle line-buffered unless it is stderr. This fixes a problem where the file list output was fully-buffered when used as part of a pipeline. With this change, files are listed as they are extracted in verbose mode. OK deraadt@ guenther@ --- bin/pax/options.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/bin/pax/options.c b/bin/pax/options.c index 2e9960168fd..cd3f5f6285c 100644 --- a/bin/pax/options.c +++ b/bin/pax/options.c @@ -1,4 +1,4 @@ -/* $OpenBSD: options.c,v 1.114 2024/04/17 18:12:12 jca Exp $ */ +/* $OpenBSD: options.c,v 1.115 2024/05/10 20:28:31 millert Exp $ */ /* $NetBSD: options.c,v 1.6 1996/03/26 23:54:18 mrg Exp $ */ /*- @@ -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); } /* -- 2.20.1