From: Jeff King <peff@peff.net>
To: Luke Mewburn <luke@mewburn.net>
Cc: gitster@pobox.com, git@vger.kernel.org
Subject: [PATCH] progress: treat "no terminal" as being in the foreground
Date: Tue, 19 May 2015 01:24:57 -0400 [thread overview]
Message-ID: <20150519052457.GA18772@peff.net> (raw)
In-Reply-To: <20150519051752.GA16173@peff.net>
On Tue, May 19, 2015 at 01:17:52AM -0400, Jeff King wrote:
> One reasonable fix (I think) would be to treat an error return from
> tcgetpgrp() as "yes, we are the foreground", like:
I think I convinced myself this is the right fix. So here it is, all
wrapped up with a commit message. I'd love to hear confirmation, though.
:)
-- >8 --
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>
---
progress.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/progress.c b/progress.c
index 43d9228..2e31bec 100644
--- a/progress.c
+++ b/progress.c
@@ -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)
--
2.4.1.396.g7ba6d7b
next prev parent reply other threads:[~2015-05-19 5:25 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-15 9:34 [PATCH] progress: no progress in background Luke Mewburn
2015-05-19 5:17 ` Jeff King
2015-05-19 5:24 ` Jeff King [this message]
2015-05-19 16:12 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150519052457.GA18772@peff.net \
--to=peff@peff.net \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=luke@mewburn.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).