Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdlib.h>
- #include <stdio.h>
- #include <sys/types.h>
- #include <unistd.h>
- #include <pthread.h>
- #include <signal.h>
- #include <string.h>
- #include <fcntl.h>
- #include<sys/mman.h>
- #include<sys/ipc.h>
- #include<sys/shm.h>
- int main(int ac,char** av) {
- int a = 0, b = 1, c = 2, i, r[5];
- for(i = 0; i < 5; i++) {
- if( (r[i] = fork()) ) {
- a = getpid();
- srandom(a);
- b = random()%10;
- sleep(b);
- exit(a+b);
- }
- }
- i = 0;
- while(-1 != waitpid(r[i], &c, 0)) {
- printf("%d %d %d %d \n", a, b, r[i], WEXITSTATUS(c));
- i++;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement