- 论坛徽章:
- 0
|
在system调用的命令里我已经将输出和出错输出重定向了,结果还是一样,不知道那个指的是那个管道
我的程序是这样写的:
int system_wrap(const char *cmdname,char *cmd)
{
char resu[10];
int status = 0;
status = system(cmd);
if(status == -1)
{
write_log_error(cmdname);
write_log_error(" don't carry out\n");
return status;
}
else
{
if(WIFEXITED(status))
{
status = WEXITSTATUS(status);
if(status == 0)//success carry out
return 0;
else
{
write_log_error(cmdname);
write_log_error(" failure ");
memset(resu, '\0', 10);
snprintf(resu, 10, "%d", status);
write_log_error(resu);
write_log_error("\n");
return status;//failure
}
}
else if(WIFSIGNALED(status))
{
write_log_error(cmdname);
write_log_error(" had been broken ");
memset(resu, '\0', 10);
snprintf(resu, 10, "%d", WTERMSIG(status));
write_log_error(resu);
write_log_error("\n");
return -2;
}
}
}
cmd命令类似于:xxx -x -xx -xxx=n > xxx.txt
另外下面这个也不对:cmd命令类似于:xxx -x -xx -xxx=n > xxx.txt 2> xxx1.txt |
|