* [PATCH] tools/xc: update tty detection in stdiostream_progress
@ 2013-02-22 20:08 Olaf Hering
2013-02-26 17:37 ` Ian Jackson
0 siblings, 1 reply; 3+ messages in thread
From: Olaf Hering @ 2013-02-22 20:08 UTC (permalink / raw)
To: xen-devel
# HG changeset patch
# User Olaf Hering <olaf@aepfle.de>
# Date 1361561865 -3600
# Node ID 1b36a6c0a956cc94ddb0024099bf60fb4cbe02d7
# Parent dc086ced6b0c7ecf21e56155f42fb16dabe39097
tools/xc: update tty detection in stdiostream_progress
As suggested by IanJ:
Check isatty only once to preserve the errno of ->progress users, and to
reduce the noice in strace output.
Signed-off-by: Olaf Hering <olaf@aepfle.de>
diff -r dc086ced6b0c -r 1b36a6c0a956 tools/libxc/xtl_logger_stdio.c
--- a/tools/libxc/xtl_logger_stdio.c
+++ b/tools/libxc/xtl_logger_stdio.c
@@ -35,6 +35,7 @@ struct xentoollog_logger_stdiostream {
xentoollog_level min_level;
unsigned flags;
int progress_erase_len, progress_last_percent;
+ int isatty;
};
static void progress_erase(xentoollog_logger_stdiostream *lg) {
@@ -118,7 +119,7 @@ static void stdiostream_progress(struct
lg->progress_last_percent = percent;
- if (isatty(fileno(lg->f)) <= 0) {
+ if (!lg->isatty) {
stdiostream_message(logger_in, this_level, context,
"%s: %lu/%lu %3d%%",
doing_what, done, total, percent);
@@ -166,6 +167,7 @@ xentoollog_logger_stdiostream *xtl_creat
newlogger.f = f;
newlogger.min_level = min_level;
newlogger.flags = flags;
+ newlogger.isatty = isatty(fileno(lg->f)) > 0;
if (newlogger.flags & XTL_STDIOSTREAM_SHOW_DATE) tzset();
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] tools/xc: update tty detection in stdiostream_progress
2013-02-22 20:08 [PATCH] tools/xc: update tty detection in stdiostream_progress Olaf Hering
@ 2013-02-26 17:37 ` Ian Jackson
2013-02-27 13:37 ` Olaf Hering
0 siblings, 1 reply; 3+ messages in thread
From: Ian Jackson @ 2013-02-26 17:37 UTC (permalink / raw)
To: Olaf Hering; +Cc: xen-devel
Olaf Hering writes ("[Xen-devel] [PATCH] tools/xc: update tty detection in stdiostream_progress"):
> tools/xc: update tty detection in stdiostream_progress
>
> As suggested by IanJ:
> Check isatty only once to preserve the errno of ->progress users, and to
> reduce the noice in strace output.
>
> Signed-off-by: Olaf Hering <olaf@aepfle.de>
Thanks. But how did you test this ? It doesn't compile.
Also I think it would be better to name the struct member something
other than "isatty" since that's also the function name. In theory it
should be OK but in practice I worry about compiler warnings etc.
How about "tty" ?
Ian.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] tools/xc: update tty detection in stdiostream_progress
2013-02-26 17:37 ` Ian Jackson
@ 2013-02-27 13:37 ` Olaf Hering
0 siblings, 0 replies; 3+ messages in thread
From: Olaf Hering @ 2013-02-27 13:37 UTC (permalink / raw)
To: Ian Jackson; +Cc: xen-devel
On Tue, Feb 26, Ian Jackson wrote:
> Olaf Hering writes ("[Xen-devel] [PATCH] tools/xc: update tty detection in stdiostream_progress"):
> > tools/xc: update tty detection in stdiostream_progress
> >
> > As suggested by IanJ:
> > Check isatty only once to preserve the errno of ->progress users, and to
> > reduce the noice in strace output.
> >
> > Signed-off-by: Olaf Hering <olaf@aepfle.de>
>
> Thanks. But how did you test this ? It doesn't compile.
I noticed that compiler error but forgot to do qrefresh before sending.
> Also I think it would be better to name the struct member something
> other than "isatty" since that's also the function name. In theory it
> should be OK but in practice I worry about compiler warnings etc.
>
> How about "tty" ?
Will rename the member to tty and resend.
Olaf
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2013-02-27 13:37 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-02-22 20:08 [PATCH] tools/xc: update tty detection in stdiostream_progress Olaf Hering
2013-02-26 17:37 ` Ian Jackson
2013-02-27 13:37 ` Olaf Hering
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.