Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <sys/types.h>
- #include <unistd.h>
- #include <sys/wait.h>
- #include <stdlib.h>
- void dziecko(int a);
- int main (int argc, char *argv[])
- {
- int status;
- int pid;
- pid_t potomek;
- int i, j;
- for(i = 1; i < atoi(argv[1])+1; i++) {
- potomek = fork ();
- if (potomek == 0) {
- pid = getpid();
- for(j = 0; j < 4; j++)
- printf("Potomek: %d PID: %d PPID: %d\n", i, getpid(), getppid());
- sleep(i);
- exit(0);
- }
- }
- while ((pid = wait(&status)) > 0)
- printf("\nPID: %d, status: %d\n", pid, status);
- return 0;
- }
- void dziecko(int a)
- {
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement