《操作系统》的实验代码。
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

15 lines
487 B

  1. #include <stdio.h>
  2. #include <unistd.h>
  3. void main(void){
  4. int child_status, exec_status;
  5. int pid = fork(); //create a child
  6. if (pid==0) { // child continues here
  7. printf("Child: EXEC lec7_1\n");
  8. exec_status=execve("lec7_1",NULL,NULL);
  9. printf("Child: Why would I execute?\n");
  10. } else { // parent continues here
  11. printf("Parent: Whose your daddy?\n");
  12. child_status=wait(pid);
  13. printf("Parent: the child %d exit with %d\n",pid, child_status);
  14. }
  15. }