Skip to content

Commit a4fb76c

Browse files
peffgitster
authored andcommitted
progress: treat "no terminal" as being in the foreground
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 9a9a41d commit a4fb76c

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

progress.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,8 @@ static void clear_progress_signal(void)
7474

7575
static int is_foreground_fd(int fd)
7676
{
77-
return getpgid(0) == tcgetpgrp(fd);
77+
int tpgrp = tcgetpgrp(fd);
78+
return tpgrp < 0 || tpgrp == getpgid(0);
7879
}
7980

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

0 commit comments

Comments
 (0)