描述
system()库函数使用fork(2)创建一个子进程,该子进程使用execl(3)执行指定的shell命令,
execl("/bin/sh", “sh”, “-c”, command,...(char *) 0);
头文件
system - execute a shell command
#include
int system(const char *command...WIFEXITED(status) 用来指出子进程是否为正常退出的,如果是,它会返回一个非零值
WEXITSTATUS(status) 用来获取返回值status的低8~15数据
有了这两个宏代码就简介很多..., 总结一下,system的返回值需要通过以下三个步骤确定
首先判断子进程是否成功, status !...返回值判断 命令是否正确执行
Linux system函数返回值
父进程等待子进程终止 wait, WIFEXITED, WEXITSTATUS