Re: How does one effect O_NONBLOCK?!
- From: jt@xxxxxxxxxxx (Jens Thoms Toerring)
- Date: 2 Jun 2008 21:59:20 GMT
Edd <edd@xxxxxxxxxxxxxxxx> wrote:
Hi again Jens,
On Jun 2, 12:27 am, j...@xxxxxxxxxxx (Jens Thoms Toerring) wrote:
Edd <e...@xxxxxxxxxxxxxxxx> wrote:
Would pseudo-terminals help with this particular issue?
Yes, it would since using by a pseudo-terminal in between you
would get the child process to react exactly the same way as
it would if its stdout would be connected to a terminal (that's
why it's called a pseudo-terminal), i.e. it's stdout would be
line buffered (of course assuming that the application hasn't
changed the default buffering mode).
Ok great. Looks like I have some more reading to do, then!
;-)
But I'm curious, now; if using a pseudo-terminal allows you to create
a perfect proxy, what reason is there to use pipes? I guess larger
buffers make them more efficient for "noisy" programs?
Pipes are often used between a parent and a child process that
the parent spawned, but which didn't call exec(). So the author
wrote both the parents and the childs code and could avoid any
such issues. Then adding another layer of complexity completely
unneeded don't make sense. And it's not really a problem due
to the design of pipes as such, it's more a problem introduced
by the output buffering of the C standard output functions.
They may simply not flush the buffer to the pipe. And that's
where pseudo-terminals come to the rescue.
So normally things only get "interesting" if the childs exec()'s
a program that hasn't been written with the possiblilty of being
connected to a pipe in mind by using e.g. printf() and not flushing
the output buffer at the end of a line (or using setvbuf() etc) and
expects a kind of dialog with the user.
For the record, I will be using this function in a piece of software
used for automation of tasks. A bit like make in some ways. From the
sounds of things, pipes will probably suffice 99% of the time.
Occasionally though, I will want to capture and process child output
e.g. from pkg-config. I'm sure I won't need pseudo-terminals for pkg-
config either, but the system is scriptable, so I have to assume as
little as possible about the children that will be created.
I guess pkg-config shouldn't pose a problem since it doesn't seem
to do a "dialog" kind of thing (at least as far as I know) but just
outputs data and exits. And when it exits its buffers get flushed
automatically. So a simple pipe should be sufficient with that.
Regards, Jens
--
\ Jens Thoms Toerring ___ jt@xxxxxxxxxxx
\__________________________ http://toerring.de
.
- Follow-Ups:
- Re: How does one effect O_NONBLOCK?!
- From: Edd
- Re: How does one effect O_NONBLOCK?!
- References:
- How does one effect O_NONBLOCK?!
- From: Edd
- Re: How does one effect O_NONBLOCK?!
- From: Jens Thoms Toerring
- Re: How does one effect O_NONBLOCK?!
- From: Edd
- Re: How does one effect O_NONBLOCK?!
- From: Jens Thoms Toerring
- Re: How does one effect O_NONBLOCK?!
- From: Edd
- How does one effect O_NONBLOCK?!
- Prev by Date: Re: How does one effect O_NONBLOCK?!
- Next by Date: Re: How does one effect O_NONBLOCK?!
- Previous by thread: Re: How does one effect O_NONBLOCK?!
- Next by thread: Re: How does one effect O_NONBLOCK?!
- Index(es):
Relevant Pages
|