diff options
author | Olaf Hering <olaf@aepfle.de> | 2013-02-27 14:16:36 +0000 |
---|---|---|
committer | Ian Jackson <Ian.Jackson@eu.citrix.com> | 2013-02-28 16:13:46 +0000 |
commit | 2f80ac9c0e8fe117b3e9cf71f799b482c6ca312f (patch) | |
tree | ef6097668e387486d184f2541f637b278c73681b /tools | |
parent | 345cf1f8c7a0d563c735d63c72048e2747393a46 (diff) | |
download | xen-2f80ac9c0e8fe117b3e9cf71f799b482c6ca312f.tar.gz xen-2f80ac9c0e8fe117b3e9cf71f799b482c6ca312f.tar.bz2 xen-2f80ac9c0e8fe117b3e9cf71f799b482c6ca312f.zip |
tools/xentoollog: 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>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/libxc/xtl_logger_stdio.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/tools/libxc/xtl_logger_stdio.c b/tools/libxc/xtl_logger_stdio.c index 25b2464e72..2e73c862b9 100644 --- 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 tty; }; static void progress_erase(xentoollog_logger_stdiostream *lg) { @@ -118,7 +119,7 @@ static void stdiostream_progress(struct xentoollog_logger *logger_in, lg->progress_last_percent = percent; - if (isatty(fileno(lg->f)) <= 0) { + if (!lg->tty) { stdiostream_message(logger_in, this_level, context, "%s: %lu/%lu %3d%%", doing_what, done, total, percent); @@ -166,6 +167,7 @@ xentoollog_logger_stdiostream *xtl_createlogger_stdiostream newlogger.f = f; newlogger.min_level = min_level; newlogger.flags = flags; + newlogger.tty = isatty(fileno(newlogger.f)) > 0; if (newlogger.flags & XTL_STDIOSTREAM_SHOW_DATE) tzset(); |