I have created a C library to span a process with given input and receive its output.
One cannot just write to stdin of a process and then read its stdout through pipes, because this way it may lead to a deadlock.
Instead use my library:
It is an alpha release, tested on Linux.
During its development I managed to crash Linux: https://bugzilla.kernel.org/show_bug.cgi?id=198549