Title: include stdio.h include unistd.h include stdlib.h
1include ltstdio.hgtinclude ltunistd.hgtinclude
ltstdlib.hgtinclude ltstring.hgtmain(int argc,
char argv ) int f_des2
static char messageBUFSIZ if (argc ! 2)
fprintf(stderr, "Usage s message\n",
argv) exit(1) if (pipe(f_des) -1)
// generate the pipe perror("Pipe")
exit(2) switch (fork( )) case -1
perror("Fork") exit(3) case 0
// In the child
close(f_des1) if (read(f_des0, message,
BUFSIZ) ! -1) printf("Message received
by child s\n", message)
fflush(stdout) else
perror("Read") exit(4) break
default // In the Parent
close(f_des0) if
(write(f_des1, argv1, strlen(argv1)) ! -1)
printf("Message sent by parent
s\n", argv1) fflush(stdout)
else perror("Write") exit(5)
exit(0)