gabriel rosenkoetter on 31 Oct 2006 20:15:41 -0000


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: [PLUG] Basic unix pipe question


On Tue, Oct 31, 2006 at 03:00:32PM -0500, Ben Dugan wrote:
> I don't get any output (on stdout) from program2 until program1
> finishes. (I'm trying this out with simple C programs; program1 does a
> printf once every second, while program2 just watches stdin using fscanf
> and copies its stdin to stdout.)
> 
> I've been googling and looking at some reference books I have, but I
> can't really figure out why this is. I can't coerce program2's output to
> happen sooner using flush, either.
> 
> Any suggestions or explanations?

It depends on your shell.

POSIX doesn't have any MUST or even SHOULD statements wrt buffered
I/O in pipelines, and shells are free to do whatever they like.

If you want control over this, you need to use SysV IPC. Probably,
Unix domain sockets are what you want. Possibly, SHM + SEM.

-- 
gabriel rosenkoetter
gr@eclipsed.net

Attachment: pgpe5FuR68VTP.pgp
Description: PGP signature

___________________________________________________________________________
Philadelphia Linux Users Group         --        http://www.phillylinux.org
Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce
General Discussion  --   http://lists.phillylinux.org/mailman/listinfo/plug