execl() and inheritied streams
Tue Sep 28 23:24:56 CEST 2004
Thanks for your kind and helpful reply, Donn! :)
"Donn Cave" <donn at u.washington.edu> wrote in message
news:donn-209231.13080428092004 at gnus01.u.washington.edu...
> sys.stdin etc. are objects that live in the Python interpreter.
> Basically, they're a buffer plus a file descriptor, plus some
> functions. Similar to the C stdio FILE object, which in fact
> is underneath the Python fileobject.
> Objects in interpreter memory space do not survive an exec.
> You want to remap the standard UNIX file descriptors 0 (input),
> 1 (output) and 2 (error). They are the system level I/O streams
> that will survive exec.
> fd = os.open(filename, os.O_WRONLY|os.O_CREAT)
> os.dup2(fd, 1)
> os.dup2(fd, 2)
More information about the Python-list