system函数相当于封装后的exec
#include
int system(const char *command);
system()函数的返回值如下:
成功:则返回进程状态值;当sh不执行时,返回127;
失败:返回-1;
#include
#include
#include
#include
#include
#include
#include
#include
int main()
{
pid_t pid;
int data = 10;
while(1){
printf("please input a data:\n");
scanf("%d",&data);
if(data == 1){
int fdSrc;
pid = fork();
if(pid > 0){
wait(NULL);
}
if(pid == 0){
//execl("./changeData","changeData","config.txt",NULL);
system("./changeData config.txt");
}
}
else{
printf("wait ,do nothing!\n");
}
}
return 0;
}
linux system函数详解 https://www.cnblogs.com/leijiangtao/p/4051387.html