embedded: redirecting stdout before you call Py_Initialize
Niels Diepeveen
niels at endea.demon.nl
Fri Mar 3 11:17:51 EST 2000
Warren Postma schreef:
>
> [probably a FAQ, I searched the Python archives but couldn't find this exact
> thing anywhere...]
>
> How do you redirect stdout to your own place, such as a Win32 anonymous
> pipe, before you even call Py_Initialize? Is the key to redirect C's
> stdout? How do you do that?
Something like this will probably work:
int stdoutfds[2];
if (_pipe(stdoutfds, 512, _O_BINARY))
....
if (_dup2(stdoutfds[1], 1) /* Redirect stdout */
....
if (_dup2(stdoutfds[1], 2) /* Redirect stderr */
....
_close(stdoutfds[1]);
--
Niels Diepeveen
Endea automatisering
More information about the Python-list
mailing list