Last active
January 15, 2020 04:47
-
-
Save dulimarta/23eb66c809c7a5a5b05d to your computer and use it in GitHub Desktop.
CS452 Lab02 - Sample 2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <sys/types.h> | |
#include <unistd.h> | |
int main(int argc, char *argv[]) | |
{ | |
int i, limit; | |
if (argc < 2) { | |
fputs("Usage: must supply a limit value\n", stderr); | |
exit(1); | |
} | |
limit = atoi(argv[1]); | |
fork(); | |
fork(); | |
pid_t who = getpid(); | |
for (i = 0; i < limit; i++) | |
printf("PID:%d %d\n", who, i); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment