#include <stdio.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <stdlib.h>
#include <unistd.h>
int main() {
int child_pid = fork();
if (child_pid != 0) {
printf("parent process\n");
waitpid(child_pid, NULL, 0);
printf("parent process continue\n");
} else {
printf("child begin to execute\n");
char *argv[]={"cp","a","b", NULL};
char *envp[]={0,NULL};
execve("/usr/bin/cp",argv,envp);
}
return 0;
}
网友评论