[Chicago] capturing output from subprocesses

Jess Balint jbalint at gmail.com
Tue Nov 8 20:47:43 CET 2005


I made a prototype you can use. It's a simple combination of creating
pipe()s for stdin and stderr, then dup2 them into the streams after a
fork(), before an exec(). I've attach the python and a test shell
script (that kills itself). You should be able to see it capture the
output. (If there is a problem with the attachments, I will put them
on a web site or something.)

Jess

On 11/8/05, Ian Bicking <ianb at colorstudy.com> wrote:
> Noel Thomas Taylor wrote:
> > Hi Ian,
> >
> > I could try that, but in the case of the real application whose output I
> > want to capture, I have no control over how much output it produces.
>
> I thought it would be an interesting test to understand exactly what is
> going on, even if it isn't exactly what you are expecting to receive.
>
> > Do you have any thoughts about recapturing the output of an aborted child
> > process before the memory that is buffering its output gets blown away?
>
> Since it is OS buffering, shouldn't the OS handle that for you?  I don't
> know; I would suggest starting with a test, then finding something that
> passes that test.
>
> --
> Ian Bicking  /  ianb at colorstudy.com  /  http://blog.ianbicking.org
> _______________________________________________
> Chicago mailing list
> Chicago at python.org
> http://mail.python.org/mailman/listinfo/chicago
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: child_process.py
Type: application/octet-stream
Size: 883 bytes
Desc: not available
Url : http://mail.python.org/pipermail/chicago/attachments/20051108/20897b1f/child_process.obj
-------------- next part --------------
A non-text attachment was scrubbed...
Name: testsh.sh
Type: application/x-sh
Size: 116 bytes
Desc: not available
Url : http://mail.python.org/pipermail/chicago/attachments/20051108/20897b1f/testsh.sh


More information about the Chicago mailing list