From bfe5dc798c0308a10fb55356324d6c3ddc52e592 Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Fri, 3 Jun 2011 05:46:11 +0000 Subject: [PATCH] support piping the output of client_test to a file or other process --- examples/client_test.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/examples/client_test.cpp b/examples/client_test.cpp index 91c883a65..89ebdb19b 100644 --- a/examples/client_test.cpp +++ b/examples/client_test.cpp @@ -1535,14 +1535,17 @@ int main(int argc, char* argv[]) #ifndef _WIN32 { winsize size; - ioctl(STDOUT_FILENO, TIOCGWINSZ, (char*)&size); - terminal_width = size.ws_col; - terminal_height = size.ws_row; + int ret = ioctl(STDOUT_FILENO, TIOCGWINSZ, (char*)&size); + if (ret == 0) + { + terminal_width = size.ws_col; + terminal_height = size.ws_row; - if (terminal_width < 64) - terminal_width = 64; - if (terminal_height < 25) - terminal_height = 25; + if (terminal_width < 64) + terminal_width = 64; + if (terminal_height < 25) + terminal_height = 25; + } } #endif