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.

57 lines
1.1 KiB

  1. #include <stdio.h>
  2. #include "util.h"
  3. main(argc, argv, environ)
  4. int argc;
  5. char **argv;
  6. char **environ;
  7. {
  8. int i;
  9. char **ep, *prog;
  10. prog = util_path_search(argv[0]);
  11. if (prog == NIL(char)) {
  12. (void) fprintf(stderr, "Cannot find current executable\n");
  13. exit(1);
  14. }
  15. util_restart(prog, "a.out", 0);
  16. i = recur(10);
  17. (void) fprintf(stderr, "terminated normally with i = %d\n", i);
  18. (void) printf("argc is %d\n", argc);
  19. for(i = 0, ep = argv; *ep != 0; i++, ep++) {
  20. (void) printf("%08x (%08x-%08x)\targv[%d]:\t%s\n",
  21. ep, *ep, *ep + strlen(*ep), i, *ep);
  22. }
  23. i = 0;
  24. for(i = 0, ep = environ; *ep != 0; ep++, i++) {
  25. (void) printf("%08x (%08x-%08x)\tenviron[%d]:\t%s\n",
  26. ep, *ep, *ep + strlen(*ep), i, *ep);
  27. }
  28. (void) fprintf(stderr, "returning with status=4\n");
  29. return 4;
  30. }
  31. recur(cnt)
  32. {
  33. int i, j, sum;
  34. if (cnt > 0) {
  35. return recur(cnt-1);
  36. } else {
  37. sum = 0;
  38. for(j = 0; j < 20; j++) {
  39. for(i = 0; i < 100000; i++) {
  40. sum += 1;
  41. }
  42. (void) printf("done loop %d\n", j);
  43. }
  44. return sum;
  45. }
  46. }