man pipe
man fork
man exec
You need two pipes, one to stuff input into the program and one to take
output from it. So basically you do the following:
1) Create the two pipes.
2) Call 'fork'
3) In the child, close the half of each pipe you're not using and then
'exec' the program you want to run.
4) In the parent, close the half of each pipe you're not using. Then
send the data to the child. Read the child's output from the output
pipe.
5) If you can't tell from the output when the child is done, catch
SIGCHLD/SIGPIPE. They'll tell you.
6) Don't forget to call wait/waitpid so you don't leave a zombie
around.
DS
> Hi All,
> I wish to send the contents of unsigned char array to the stdin of
> program and store the programs stdout in another unsigned char array
> without using temp files. The data maynot be NULL terminated. I'm
> using Linux and EGCS.
> Any ideas? I assume I should using popen, but none of my ref. manuals
> cover popen... This is only intended to be a stopgap measure until
> native support is added.
> Thanks,
> Kevin Woodward.