Is there a way for me to do something like popen () but with two FILE*s, one read only, one write only, redirecting both the stdout and stdin of the command? Or one read-write FILE*, doesn't make a difference to me
Thanks in advance
Is there a way for me to do something like popen () but with two FILE*s, one read only, one write only, redirecting both the stdout and stdin of the command? Or one read-write FILE*, doesn't make a difference to me
Thanks in advance
hello, internet!
I'm not quite sure what you mean, but you can use the shell's redirection feature to do what it sounds like you want to do: myprog < inputfile > output file
If you understand what you're doing, you're not learning anything.
Yes, thats exactly what I want to do, except not from files on disk, but rather streams controlled by my program.
hello, internet!
Try DUP/DUP2 calls if you are using Unix/Linux, if thats what you are looking for.
Help everyone you can
hmm.... so, i could do something like this?
1. make two pipes
2. fork
3. make one pipe go in each direction from child <-> parent
4. dup2 stdout and stdin on the child to the pipes
5. exec() the desired program on the child
and then the stdin and stdout of the desired program would be accessable by the pipes in the parent?
hello, internet!
Once you call exec then you will overwrite whatever you did to your child program. So setting up stdin and stdout and pipes would be useless after you call exec.
Help populate a c/c++ help irc channel
server: irc://irc.efnet.net
channel: #c
I had interpretted "File descriptors open in the calling process image remain open in the new process image, except for those for which the close-on-exec flag is set (see close(2) and fcntl(2)). Descriptors that remain open are unaffected by execve." to mean that whatever stdin and stdout are directed to before exec stay that way?
if not, then how should i do what i want to?
hello, internet!
My bad, you are right.
Help populate a c/c++ help irc channel
server: irc://irc.efnet.net
channel: #c
Thanks for the help
Unfortunately, I just realized that licensing issues of my project prevent using cygwin, and mingw doesnt have pipe() or fork() afaik.... =/
fortunately Satan has a code example for me to work off of though =D
http://msdn.microsoft.com/library/de...and_output.asp
hello, internet!