Skip to content

Commit 671e318

Browse files
committed
orchestrator: send progress bar to stderr, gate on isatty
1 parent d4915b7 commit 671e318

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

src/orchestrator.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1463,6 +1463,10 @@ static void progress_update(void) {
14631463
if (verbose)
14641464
printf("\n");
14651465
else {
1466+
/* Progress bar uses \r to overwrite itself; only useful on a TTY. Sent
1467+
* to stderr so `kasld | grep` / `kasld > out` don't capture overwrites. */
1468+
if (!isatty(STDERR_FILENO))
1469+
return;
14661470
int total =
14671471
num_active_components > 0 ? num_active_components : num_components;
14681472
int pct = total > 0 ? (done * 100) / total : 0;
@@ -1479,9 +1483,9 @@ static void progress_update(void) {
14791483
bar[i] = i < filled ? '#' : '.';
14801484
bar[bar_width] = '\0';
14811485

1482-
printf("\r%s[%s]%s %3d%% %d/%d %s%.1fs%s", c(C_DIM), bar, c(C_RESET), pct,
1483-
done, total, c(C_DIM), elapsed, c(C_RESET));
1484-
fflush(stdout);
1486+
fprintf(stderr, "\r%s[%s]%s %3d%% %d/%d %s%.1fs%s", c(C_DIM), bar,
1487+
c(C_RESET), pct, done, total, c(C_DIM), elapsed, c(C_RESET));
1488+
fflush(stderr);
14851489
}
14861490
}
14871491

0 commit comments

Comments
 (0)