os_kernel_lab/related_info/lab0/lab0_ex6.c
2015-04-16 08:43:14 +08:00

16 lines
487 B
C

#include <stdio.h>
#include <unistd.h>
void main(void){
int child_status, exec_status;
int pid = fork(); //create a child
if (pid==0) { // child continues here
printf("Child: EXEC lec7_1\n");
exec_status=execve("lec7_1",NULL,NULL);
printf("Child: Why would I execute?\n");
} else { // parent continues here
printf("Parent: Whose your daddy?\n");
child_status=wait(pid);
printf("Parent: the child %d exit with %d\n",pid, child_status);
}
}