Skip to content

Instantly share code, notes, and snippets.

@dulimarta
Last active January 15, 2020 04:47
Show Gist options
  • Save dulimarta/23eb66c809c7a5a5b05d to your computer and use it in GitHub Desktop.
Save dulimarta/23eb66c809c7a5a5b05d to your computer and use it in GitHub Desktop.
CS452 Lab02 - Sample 2
#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