psx.c 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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(int argc, char *argv[])
  12. {
  13. int iter = 1000, i;
  14. Waitmsg *w;
  15. if (argc > 1)
  16. iter = strtoul(argv[1], 0, 0);
  17. for(i = 0; i < iter; i++) {
  18. int pid;
  19. pid = fork();
  20. if (pid < 0) {
  21. print("FAIL\n");
  22. exits("FAIL");
  23. }
  24. if (pid == 0) {
  25. // execl won't work yet. varargs hell.
  26. char *args[] = {"ps", nil};
  27. exec("/amd64/bin/ps", args);
  28. fprint(2,"Exec fails: %r\n");
  29. print("FAIL\n");
  30. exits("FAIL");
  31. }
  32. w = wait();
  33. if (w == nil) {
  34. print("FAIL\n");
  35. exits("FAIL");
  36. }
  37. }
  38. // if we get here, we have survived. That's a miracle.
  39. print("PASS\n");
  40. exits("PASS");
  41. return 0;
  42. }