hogparty.c 689 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /*
  2. * hogparty
  3. *
  4. * create some talking hogs
  5. *
  6. * relies on fork, _exit, stdout and stderr, and execv
  7. *
  8. */
  9. #include <unistd.h>
  10. #include <err.h>
  11. static char *xhargv[2] = { (char *)"xhog", NULL };
  12. static char *yhargv[2] = { (char *)"yhog", NULL };
  13. static char *zhargv[2] = { (char *)"zhog", NULL };
  14. static
  15. void
  16. spawnv(const char *prog, char **argv)
  17. {
  18. pid_t pid = fork();
  19. switch (pid) {
  20. case -1:
  21. err(1, "fork");
  22. case 0:
  23. /* child */
  24. execv(prog, argv);
  25. err(1, "%s", prog);
  26. default:
  27. /* parent */
  28. break;
  29. }
  30. }
  31. int
  32. main()
  33. {
  34. spawnv("/uw-testbin/xhog", xhargv);
  35. spawnv("/uw-testbin/yhog", yhargv);
  36. spawnv("/uw-testbin/zhog", zhargv);
  37. return 0;
  38. }