Programmatic process control in C: popen3()

There are times when it's useful or necessary to use an external command as part of a program, and full control of the command's stdin, stdout, and stderr are required, rendering popen() insufficient.  This level of control is useful for, among other things, writing a GUI frontend for a console application.

I recently encountered just such an occasion, and wrote a function called popen3() (the 3 indicates that full control is given over all three of the program's standard file descriptors).  I also remembered writing a similar implementation several years ago, and dug through my old backups to find it.  To spare anyone else the burden of implementing popen3() from scratch, I've uploaded both implementations as GitHub Gists. They are released into the public domain, though attribution is appreciated.