Skip to content

Commit

Permalink
progress: treat "no terminal" as being in the foreground
Browse files Browse the repository at this point in the history
progress: treat "no terminal" as being in the foreground

Commit 85cb890 (progress: no progress in background,
2015-04-13) avoids sending progress from background
processes by checking that the process group id of the
current process is the same as that of the controlling
terminal.

If we don't have a terminal, however, this check never
succeeds, and we print no progress at all (until the final
"done" message). This can be seen when cloning a large
repository; instead of getting progress updates for
"counting objects", it will appear to hang then print the
final count.

We can fix this by treating an error return from tcgetpgrp()
as a signal to show the progress.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Jeff King authored and Junio C Hamano committed May 19, 2015
1 parent 9a9a41d commit a4fb76c
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion progress.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ static void clear_progress_signal(void)

static int is_foreground_fd(int fd)
{
return getpgid(0) == tcgetpgrp(fd);
int tpgrp = tcgetpgrp(fd);
return tpgrp < 0 || tpgrp == getpgid(0);
}

static int display(struct progress *progress, unsigned n, const char *done)
Expand Down

0 comments on commit a4fb76c

Please sign in to comment.