faqts : Computers : Programming : Languages : PHP : Common Problems : Files : Tips and Tricks : File Handling

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

5 of 23 people (22%) answered Yes
Recently 0 of 10 people (0%) answered Yes

Entry

How do you redirect stdout to your own place, such as a Win32 anonymous pipe, before you even call Py_Initialize?

Mar 3rd, 2000 20:32
Nathan Wallace, Niels Diepeveen


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]);