Author Kevin.Barry
Recipients Kevin.Barry, emmanuel, vstinner
Date 2013-03-17.21:13:36
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1363554816.73.0.182799254544.issue14916@psf.upfronthosting.co.za>
In-reply-to
Content
emmanuel,

Thanks for the suggestion. Your workaround is exactly the same as using dup2 (in C) to replace stdin/stdout/stderr with the pty, however. If you added the following lines to your C code, it would have the same effect as the command-line redirection in the workaround:

dup2(fileno(file), STDIN_FILENO);
dup2(fileno(file), STDOUT_FILENO);
dup2(fileno(file), STDERR_FILENO);

In fact, that's exactly what bash does after forking, just before executing "exe". In most cases, developers who use PyRun_InteractiveLoop in a pty probably also do exactly that, which is why I'm the only one who's reported this as a bug. For applications like mine, however, where the interactive Python session needs to be an unobtrusive add-on to an otherwise-complete program, this solution won't work. The standard file descriptors aren't disposable in most of the programs I work on.

Thanks again!

Kevin Barry
History
Date User Action Args
2013-03-17 21:13:36Kevin.Barrysetrecipients: + Kevin.Barry, vstinner, emmanuel
2013-03-17 21:13:36Kevin.Barrysetmessageid: <1363554816.73.0.182799254544.issue14916@psf.upfronthosting.co.za>
2013-03-17 21:13:36Kevin.Barrylinkissue14916 messages
2013-03-17 21:13:36Kevin.Barrycreate