#include #include int main() { pid_t newpid; int fd1[2], fd2[2]; char m1[] = "Final Exam 2013\n"; char m2[] = "Today is 10th December\n"; char rbuf1[256]; char rbuf2[256]; int cn1, cn2; if ((pipe(fd1)== -1)) printf(" error \n"); printf("fd1 %d %d \n", fd1[0], fd1[1]); dup(fd1[0]); dup(fd1[1]); //#1 show the open file descriptor table here write(4, m1, sizeof(m1)); cn1 = read(5, rbuf1, 256); write(1, rbuf1, cn1); //#2 show the structure of pipe fd1 with the respect the current process if ((pipe(fd2)== -1)) printf(" error \n"); printf("fd1 %d %d \n", fd2[0], fd2[1]); if ((newpid = fork()) == -1) { printf("error \n"); return 0;} if (newpid >0 ) { //parent write(4, m2, sizeof(m2)); //#3 show the open file descriptor table here } else { //child cn2 = read(3, rbuf2, 256); write(1, rbuf2,cn2); int fd3[2]; if ((pipe(fd3)== -1)) printf(" error \n"); printf("fd1 %d %d \n", fd3[0], fd3[1]); //#4 Show the open file descriptor table for parent + child // other code } return 0; }