du: Print progress information to stderr

* On SIGINFO, print the current path to stderr rather than stdout.

* Do so immediately, instead of the next time we finish a directory.

* Document this behavior in the manual page.

PR:		296861
MFC after:	1 week
Fixes:          d1588599c0 ("Report the next directory being scanned ...")
Reviewed by:	wollman
Differential Revision:	https://reviews.freebsd.org/D58702
This commit is contained in:
Dag-Erling Smørgrav committed 2026-08-08 02:10:46 +02:00
1 parent 4c4bad4421
commit fd79bf6344
2 files changed
+15 -5

No files matched your search

+11 -1
View File
@@ -25,7 +25,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.Dd June 9, 2026
.Dd August 7, 2026
.Dt DU 1
.Os
.Sh NAME
@@ -195,6 +195,16 @@ and
.Fl Fl si
options all override each other; the last one specified determines
the block counts used.
.Pp
If
.Nm
receives a
.Dv SIGINFO
(see the
.Cm status
argument for
.Xr stty 1 )
signal, the current file will be written to the standard error output.
.Sh ENVIRONMENT
.Bl -tag -width BLOCKSIZE
.It Ev BLOCKSIZE
+4 -4
View File
@@ -270,6 +270,10 @@ main(int argc, char *argv[])
xo_open_container("disk-usage-information");
xo_open_list("paths");
for (errno = 0; (p = fts_read(fts)) != NULL; errno = 0) {
if (info) {
info = 0;
(void)fprintf(stderr, "\t%s\n", p->fts_path);
}
switch (p->fts_info) {
case FTS_D: /* Ignore. */
if (ignorep(p))
@@ -284,10 +288,6 @@ main(int argc, char *argv[])
if (p->fts_level <= depth && check_threshold(p))
print_file_size(p);
if (info) {
info = 0;
(void)printf("\t%s\n", p->fts_path);
}
break;
case FTS_DC: /* Ignore. */
break;