正确使用system方法,判断返回值
int exeCmd(const char *cmd) { pid_t status; status = system(cmd); if (-1 == status) { WriteLog("system error!"); } else { WriteLog("exit status value = [0x%x] ", status); if (WIFEXITED(status)) { if (0 == WEXITSTATUS(status)) { WriteLog("run CMD script successfully. "); return 0; } else { WriteLog("run CMD=[%s] script fail, script exit code: %d ", cmd,WEXITSTATUS(status)); } } else { WriteLog("exit status = [%d] ", WEXITSTATUS(status)); } } return -1; }