From d4b0c6673617e5694c50499194367c9feffa4914 Mon Sep 17 00:00:00 2001 From: Joshua Miller Date: Tue, 18 Feb 2014 14:44:29 -0600 Subject: [PATCH] verify read from stdin --- src/udpipe_threads.cpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/udpipe_threads.cpp b/src/udpipe_threads.cpp index 3d95e96..59ec5a5 100644 --- a/src/udpipe_threads.cpp +++ b/src/udpipe_threads.cpp @@ -435,22 +435,20 @@ void* senddata(void* _args) while (1) { - bytes_read = read(fileno(stdin), outdata, BUFF_SIZE); int ssize = 0; int ss; - if(bytes_read == 0) { + bytes_read = read(fileno(stdin), outdata, BUFF_SIZE); - // fprintf(stderr, "Transfer complete\n"); - - // sleep (1); + if (bytes_read < 0){ + fprintf(stderr, "[udpipe_threads] unable to read from stdin\n"); + exit(1); + } - //UDT::close(client); - //UDT::close(*args->usocket); + if(bytes_read == 0) { return NULL; - //exit(0); }