diff --git a/include/boost/histogram/detail/term_info.hpp b/include/boost/histogram/detail/term_info.hpp index 8d34a4ba..8eb19666 100644 --- a/include/boost/histogram/detail/term_info.hpp +++ b/include/boost/histogram/detail/term_info.hpp @@ -69,9 +69,9 @@ inline bool utf8() { inline int width() { int w = 0; #if defined TIOCGWINSZ - struct winsize ws; - ioctl(STDOUT_FILENO, TIOCGWINSZ, &ws); - w = (std::max)(static_cast(ws.ws_col), 0); // not sure if ws_col can be less than 0 + struct winsize ws{}; + if (ioctl(STDOUT_FILENO, TIOCGWINSZ, &ws) == 0) + w = (std::max)(static_cast(ws.ws_col), 0); // not sure if ws_col can be less than 0 #endif env_t env("COLUMNS"); const int col = (std::max)(static_cast(env), 0);