[Chicago] capturing output from subprocesses

Jess Balint jbalint at gmail.com
Sat Nov 12 00:47:33 CET 2005


Ok, I've attached a pty version. I've tested it on Linux and Solaris
and it seems to work well. I left your select timeout in there for
illustration, but I'm still not sure what you were getting at with
that. I set the select timeout to '3' and the ticker.py to sleep the
number of seconds as the incrementer. This way you see a few 'ticks'
in the output before the parent kills it. Let me know if this one
works ok and makes sense.

Jess

On 11/11/05, Jess Balint <jbalint at gmail.com> wrote:
> > The child process in the real application I want to use this for is
> > written in fortran, so I can't use the techniques you mentioned.
> >
> > I had already sought out second and third opinions on this, so now I am
> > really convinced that there is no way to get the effect I want without
> > using pseudo-terminals.
>
> Yes, I think that's the only thing you have influence on at this
> point. Using forkpty() and connecting it to the pipe might work.
> Another option might be to use an LD_PRELOAD with an init routine that
> calls setbuf(). I am trying to find a simple, non-intrusive way to do
> this, I will let you know if I come up with something.
>
> > > The non-blocking io is not relevant to any of this.
> >
> > Too bad. If I can ask you one more thing: what is the proper purpose of
> > using fcntl to set a file descriptor to non-blocking IO if not to achieve
> > the behavior I'm looking for in this problem?
>
> Non-blocking IO is something that allows a read() or write() call to
> return when a file descriptor is not ready. So if you are reading from
> a network connection and nothing has come through, a normal read()
> call would block (and wait for something). A non-blocking attribute
> added to the socket will allow a read() call to return so you can do
> other stuff until it is ready.
>
> Jess
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: child_process_3.py
Type: application/octet-stream
Size: 1750 bytes
Desc: not available
Url : http://mail.python.org/pipermail/chicago/attachments/20051111/30f6a3de/child_process_3.obj
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ticker.py
Type: application/octet-stream
Size: 142 bytes
Desc: not available
Url : http://mail.python.org/pipermail/chicago/attachments/20051111/30f6a3de/ticker.obj


More information about the Chicago mailing list