Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdlib.h>
- #include <stdio.h>
- #include <unistd.h>
- int
- main(int argc, char ** argv) {
- int noProcs;
- int i;
- pid_t parent, child;;
- if (sscanf (argv[1], "%i", &noProcs)!=1)
- { printf ("error - not an integer"); }
- printf("As esu tevas: pid = %d ppid = %d\n", getpid(), getppid());
- parent = fork();
- if (parent == 0) {
- printf("As esu vaikas: pid = %d ppid = %d\n", getpid(), getppid());
- for (i = 0; i < noProcs; ++i) {
- child = fork();
- if (child == 0) {
- printf("As esu anukas: pid = %d ppid = %d\n", getpid(), getppid());
- exit(0);
- }
- }
- exit(0);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement