From 5822bce3761f1afae95bc41218a83f571a681d44 Mon Sep 17 00:00:00 2001 From: Steffan Byrne Date: Fri, 2 Dec 2016 21:26:37 -0500 Subject: [PATCH] Made getTerminalWidth detect if it is running in a terminal before trying to get the width. --- src/util.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/util.cpp b/src/util.cpp index f88f26f..e90392d 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -379,9 +379,16 @@ void Util::setFilePermissions(const boost::filesystem::path& path, const boost:: int Util::getTerminalWidth() { - struct winsize w; - ioctl(STDOUT_FILENO, TIOCGWINSZ, &w); - return static_cast(w.ws_col); + int width; + if(isatty(STDOUT_FILENO)) + { + struct winsize w; + ioctl(STDOUT_FILENO, TIOCGWINSZ, &w); + width = static_cast(w.ws_col); + } + else + width = 10000;//Something sufficiently big + return width; }