ПРОГА СЛЕДУЮЩАЯ:
#include <sys/types.h>
#include <unistd.h>
#include <stdio.h>
int main() {
int fd1[2],fd2[2],a,b,result;
size_t size;
char resstring[11];
if (pipe(fd1)<0){
printf("ERROR CREATE 1 PIPE \n");
return -1;
}
if (pipe(fd2)<0){
printf ("ERROR CREATE 2 PIPE \n");
return -1;
}
result = fork();
if (result<0) {
printf("CANNOT CREATE PROCESS \n");
return -1;
}
else if (result) {
close(fd1[0]);
close(fd2[1]);
size = write(fd1[1],"HELLO WORLD!",11);
if (size<0){
printf("ERROR ON RECORDING!!! \n");
return -1;
}
close (fd1[1]);
printf("PARENT exit \n");
}else {
close(fd1[1]);
close(fd2[0]);
size= read(fd1[0],resstring,11);
if(size<0) {
printf ("CAN't read \n");
return -1;
}
printf ("I READ: %s \n",resstring);
size= write(fd2[1],resstring,11);
printf ("I am a CHILD and I SEND: %s \n",resstring);
close (fd1[0]);
close (fd2[1]);
}
if (result) {
size= read (fd2[0],resstring,11);
printf ("I PROCEESS FATHER AND I READ: %s \n",resstring);
close (fd2[0]);
}
return 0;
ПРИ ЛИНКОВКЕ ВЫДАЕТ:
/home/master/tmp/ccW91dhS.o(.eh_frame+ox11): undefined reference to `__gxx_personality_v0`
collect2: ld returned 1 exit status