system函数相当于封装后的exec
c
#include <stdlib.h>
int system(const char *command);
system()函数的返回值如下:
成功:则返回进程状态值;当sh不执行时,返回127;
失败:返回-1;
c
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <stdlib.h>
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