replace function call system to getExecResult

pull/37/head
YuQing 2019-12-06 11:49:35 +08:00
parent dd34251817
commit 41e4e6f079
2 changed files with 22 additions and 4 deletions

View File

@ -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

View File

@ -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);