Be careful of buffering issues!
Update
, 2009-02-05: This is for POSIX systems like Linux. It won't work on Windows.
Files currently attached to this page:
popen2.c
1.4kB