From 41e4e6f079ae0f681edd8ac9bc1519db7f24cba3 Mon Sep 17 00:00:00 2001 From: YuQing <384681@qq.com> Date: Fri, 6 Dec 2019 11:49:35 +0800 Subject: [PATCH] replace function call system to getExecResult --- HISTORY | 4 ++++ src/logger.c | 22 ++++++++++++++++++---- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/HISTORY b/HISTORY index e8bd699..42eff34 100644 --- a/HISTORY +++ b/HISTORY @@ -1,4 +1,8 @@ +Version 1.43 2019-12-06 + * replace function call system to getExecResult, + system is the deprecated function in iOS 11 + Version 1.42 2019-12-03 * add function get_gzip_command_filename * function create_work_threads changed diff --git a/src/logger.c b/src/logger.c index f15e602..241200e 100644 --- a/src/logger.c +++ b/src/logger.c @@ -705,7 +705,9 @@ static void *log_gzip_func(void *args) struct log_filename_array filename_array; char log_filepath[MAX_PATH_SIZE]; char full_filename[MAX_PATH_SIZE + 32]; + char output[512]; int prefix_len; + int result; int i; pContext = (LogContext *)args; @@ -735,10 +737,22 @@ static void *log_gzip_func(void *args) log_filepath, filename_array.filenames[i]); snprintf(cmd, sizeof(cmd), "%s %s", get_gzip_command_filename(), full_filename); - if (system(cmd) == -1) - { - fprintf(stderr, "execute %s fail\n", cmd); - } + + result = getExecResult(cmd, output, sizeof(output)); + if (result != 0) + { + fprintf(stderr, "file: "__FILE__", line: %d, " + "exec command \"%s\" fail, " + "errno: %d, error info: %s", + __LINE__, cmd, result, STRERROR(result)); + break; + } + if (*output != '\0') + { + fprintf(stderr, "file: "__FILE__", line: %d, " + "exec command \"%s\", output: %s", + __LINE__, cmd, output); + } } log_free_filename_array(&filename_array);