fork.c 741 B

123456789101112131415161718192021222324252627282930313233343536
  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 <lib9.h>
  11. void
  12. main(void)
  13. {
  14. static int c;
  15. int pid;
  16. pid = sys_rfork(RFMEM|RFPROC);
  17. if (pid < 0) {
  18. print("FAIL: sys_rfork\n");
  19. exits("FAIL");
  20. }
  21. if (pid > 0) {
  22. c++;
  23. }
  24. if (pid == 0) {
  25. print("PASS\n");
  26. exits("PASS");
  27. }
  28. if (c > 1) {
  29. print("FAIL\n");
  30. exits("FAIL");
  31. }
  32. exits("PASS");
  33. }