Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 1 #include <stdio.h>
- 2 #include <stdlib.h>
- 3 #include <unistd.h>
- 4 #include <sys/types.h>
- 5 #include <string.h>
- 6 #include <inttypes.h>
- 7
- 10
- 11 int main(int argc, char* argv[])
- 12 {
- 13 int child_pid;
- 14 int count = 0;
- 16 int n = 0;
- 17 int i;
- 18 char bufor[1024], tmp[1024];
- sprintf(tmp, "%d ", getpid());
- strcpy(bufor, argv[2]);
- strcat(bufor, tmp);
- 21 n = atoi(argv[1]);
- 27 for (i = 0; i < n; i++) {
- 29 child_pid = fork();
- 30
- 31 if (child_pid == 0) {
- 47 //char* args[] = { argv[0], n - 1, bufor, NULL };
- 48 //execv(args[0], args);
- 49 }
- 50 }
- 51
- 52 for (i = 0; i < n; i++) {
- 53 int a;
- 54 wait(&a);
- 55 }
- 56
- 57 printf("Rodzic: %i\n", getppid());
- 58 printf("Potomek: %i\n", getpid());
- 61 return 0;
- 62 }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement