-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvatersohn.c
More file actions
43 lines (34 loc) · 903 Bytes
/
vatersohn.c
File metadata and controls
43 lines (34 loc) · 903 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/wait.h>
#define N 4
int main()
{
int c, ret;
pid_t pid[N];
char *a[N]={"Yeah","asdf zu kurz","af ds","qas"};
for(c=0; c<N; c++) {
pid[c] = fork();
if(pid[c]>0)
printf("du wirst geboren um was schoenes zu tun!\n");
ret=wait(NULL);
if(pid[c] == -1) {
perror("fork");
exit(EXIT_FAILURE);
}
if(pid[c] == 0) {/*Sohn*/
printf("PID des Sohnes %i= %i\n", c+1, getpid());
return 0/*exit(EXIT_SUCCESS)*/;}
printf("%s\n",a[c]);
}
/*for(c=0; c<N; c++) {
ret=wait(NULL);
printf("\n%c",a[c]);
if(ret == -1) {
perror("wait");
exit(EXIT_FAILURE);}
}*/
return 0;
// exit(EXIT_SUCCESS);
}