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.
 
 
 

17 lines
286 B

  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <unistd.h>
  4. int main(int argc, char **argv) {
  5. if (argc != 2) {
  6. printf("Usage: %s [n]\n", argv[0]);
  7. exit(1);
  8. }
  9. int n = atoi(argv[1]);
  10. for (int i = 0; i < n; ++i) {
  11. fork();
  12. sleep(5);
  13. }
  14. }