This should work. You should check for read() > 0 instead of !=0.
Code:
while( (rv = read(fd2[0], line, MAXLINE)) > 0)
Usually for any file, socket, pipe and any other stream read, we should always read in a loop and check for various conditions.
- Dheeraj