From: Alexey Chernobaev Date: Wed, 29 Aug 2018 17:30:38 +0000 (+0300) Subject: fputs uncommented, checks added X-Git-Tag: submit/tizen/20180911.125435~23 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=51608af1a273200222df2e6a27c8b5f7c2a6f381;p=sdk%2Ftools%2Fprofctl.git fputs uncommented, checks added --- diff --git a/profctl.c b/profctl.c index 7241ac4..cd48375 100644 --- a/profctl.c +++ b/profctl.c @@ -131,20 +131,25 @@ static FILE *pipef; static void *output_thread(void *arg) { - size_t lsize = 0; - char *buffer = NULL; - openFileProcess(); int linesRead = 0; + char *buffer = NULL; + size_t lsize = 0; + while (getline(&buffer, &lsize, pipef) != -1) { - fputs(buffer, data_file_out); ++linesRead; + if (fputs(buffer, data_file_out) < 0) { + log_error("fputs failed - exiting"); + break; + } } + free(buffer); if (verbose) { log_error("output thread exits (%d lines read)", linesRead); } + exit(0); } @@ -173,7 +178,9 @@ static void finish() unlink(pname); } } - fflush(data_file_out); + if (data_file_out != NULL) { + fflush(data_file_out); + } log_error("=== finished ==="); kill(getpid(), SIGKILL); }