-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
Jacob Fugal wrote: | Michael Ryan Byrd wrote: | | So, in C, is there a way to capture the stdout from a function? | | | | I have FunctionX which printfs a bunch of stuff. I'd like to capture | that stuff | | into a string without it printing and do a bunch of modifications to | it before | | printing. | | | | Did that make sense? Any ideas how I can do that? | | | | MRB | | possibly: | | ~ * fork | ~ * connect the stdout of the child process to stdin of the main process | ~ * have the main process collect stdin into a string | ~ * execute the method in the child process | ~ * the child process outputs some terminator string | ~ * the main process recognizes that terminator and stops collecting | ~ * child process terminates | ~ * parent process goes happily on its way with the new data | | ? | | Jacob
I realized after sending this that you can probably reconnect the existing process' stdout to its own stdin for a finite period without forking. If not, the above should work, but don't ask me for finer details about how to do the above in C -- I don't remember how myself, I'm just pretty sure it can be done. :)
Jacob -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.3 (GNU/Linux)
iD8DBQFAEEBo/PO7QochUiQRAmWqAKCB7fUsgxkDaWFrX2Ij2UZKCNi4RQCgmN06 +uYDjd9l4w49Sb8Wgof+it8= =wDfd -----END PGP SIGNATURE-----
____________________
BYU Unix Users Group http://uug.byu.edu/ ___________________________________________________________________
List Info: http://uug.byu.edu/cgi-bin/mailman/listinfo/uug-list
