I know of two approaches
1) fork, dup2, execl (you can see this approach in minicom or busybox telnet)
I'm used to going through method #1 but a friend pointed out that you can do the redirection within the shell via "1>&<file descriptor>" in the command string. This moves about 30 lines of code down to aout 2-3.
Can anyone lend some insight as to why one might prefer method #1 over method #2 or vice versa? Even thoguht I first learned to do this kind of thing via method #1, I'm favoring method #1.