create your own set of pipes, dup2 them onto stdin and out in the child, exec. pseudocode:
Code:
pipe(rpipes);
pipe(wpipes);
fork()
child:
close(wpipes[1]);
close(rpipes[0]);
dup2(wpipes[0], STDIN);
dup2(rpipes[1], STDOUT);
close(wpipes[0]);
close(rpipes[1]);
exec(..)
parent:
close(wpipes[0]);
close(rpipes[1]);
//write to stdin
write(wpipes[1], ...);
//read from stdout
read(rpipes[0], ...);
when you create a set of pipes with the pipe call, you r creating a read pipe and a write pipe. w/e u write into the write pipe can be read from the read pipe. pipe[0] is for reading, pipe[1] is for writing. the parent and child share a file descriptor table, so when the child writes to pipe[1], the parent can read what child wrote from pipe[0]. the dup2 function is used to duplicate file descriptors. when u say dup2(fd1, fd2); fd2 is closed, and reopened on fd1. this means that any write to fd2 or fd1 will both be to the same descriptor. they both refer to the same entry in the process's file table, fd1. the effect of dup2(pipe[0], STDIN), is that the read end of the pipe now becomes standard input. so when the process goes to read from STDIN, it will actually be reading from the pipe. HTH, i'd advise picking up this book as well:
http://www.kohala.com/start/apue.html