#define DRV_PRINT(format,...) printf(" %s" " "__FILE__": %05d"format"\n",DB_timeString(), __LINE__,##__VA_ARGS__)
int my_system(const char* cmd)
{
FILE * fp = NULL;
int res = 0;
char buf[1024];
if (cmd == NULL){
DRV_PRINT("cmd is NULL!");
return -1;
}
if ((fp = popen(cmd, "w") ) == NULL) {
DRV_PRINT("popen error: %s", strerror(errno));
return -1;
}
#if 0
while(fgets(buf, sizeof(buf), fp)){
DRV_PRINT("%s", buf);
ms_delay(5);
}
#endif
if ( (res = pclose(fp)) == -1) {
DRV_PRINT("close popen file pointer fp error!");
return res;
} else if (res == 0) {
return res;
} else {
DRV_PRINT("popen res is :%d", res);
return res;
}
return res;
}
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交