Código
>
void write_pipe(int fd, void *buf, char *pipe) { int flag = 0, bytes; do { fd = open(pipe, O_WRONLY); if (fd == -1) { sleep(5); } else flag = 1; } while (flag == 0); bytes = write(fd, buf, sizeof(buf)); close(fd); } void read_pipe(int fd, void *buf, char *pipe) { int flag = 0, bytes; do { fd = open(pipe, O_RDONLY); if (fd == -1) { sleep(5); } else flag = 1; } while (flag == 0); bytes = read(fd, buf, sizeof(buf)); close(fd); }
Y asi llamo la función en el main
Código
struct data dt; write_pipe(fd[0],(struct data*)&dt, argv[8]);