fork.c 716 B

1234567891011121314151617181920212223242526272829303132333435
  1. /*
  2. * This file is part of the UCB release of Plan 9. It is subject to the license
  3. * terms in the LICENSE file found in the top-level directory of this
  4. * distribution and at http://akaros.cs.berkeley.edu/files/Plan9License. No
  5. * part of the UCB release of Plan 9, including this file, may be copied,
  6. * modified, propagated, or distributed except according to the terms contained
  7. * in the LICENSE file.
  8. */
  9. #include <u.h>
  10. #include <libc.h>
  11. int main()
  12. {
  13. static int c;
  14. int pid;
  15. pid = rfork(RFMEM|RFPROC);
  16. if (pid < 0) {
  17. print("FAIL\n");
  18. exits("FAIL");
  19. }
  20. if (pid > 0) {
  21. c++;
  22. }
  23. if (pid == 0) {
  24. print("PASS\n");
  25. exits("PASS");
  26. }
  27. if (c > 1) {
  28. print("FAIL\n");
  29. exits("FAIL");
  30. }
  31. return 0;
  32. }