consider the following:
- a parent process with a child
- child runs another program using exec system call
- parent and child communicating through a bi-directional pipe(named MAINPIPE in rest)
- the child is a server binding on a port(e.g. 5000)
my program should work as follows:
if child receives a certain message from a client create another bi-directional pipe to his parent and send/receive some info.
the problem is:
when I create a pipe in the child (using pipe()
) and pass the file descriptors to the parent (using MAINPIPE), parent gets "Bad file descriptor" error message when trying to read from pipe.
any idea?
EDIT:
guys,
my problem isn't passing file-desciptors of new pipe -that is created in child process- to parent, i've already done that using MAINPIPE,
but problem is : parent can't read from new pipe, got this error message "bad file descriptor" it seems that the file descriptors is closed in parent process!