On Wed, 28 Apr 2010 12:17:44 +0200 Michal Hlavinka wrote:
> On Tuesday 27 April 2010 17:15:28 David Korn wrote:
> > cc: [email protected]
> > Subject: Re: [ast-users] ksh bugs?

> > > 8)
> > > echo foo | od /dev/fd/0
> > > od: /dev/fd/0: No such device or address
> > 
> > This is because Linux doesn't support /dev/fd/0 for socketpair which
> > is used by ksh93 for pipelines.  I believe that this is a Linux bug.

> Could you provide more info about this? I could try to get it fixed if it's 
> really a linux bug.

> I've tried above command in bash and mksh and both worked, but I guess they 
> use different mechanism for pipelines.

> I've found there are some socketpair tests in src/lib/libast/features/lib and 
> src/cmd/ksh93/features/poll what are they used for?

ksh uses socketpair(PF_FILE, SOCK_STREAM, 0, ...) instead of pipe(...) for pipes
on systems that do not provide a way to peek pipe() data (without advancing the 
read pointer)

this allows, e.g., the shell to read a line at a time from piped input
instead of byte by byte (otherwise it could consume data intended for subsequent
processes or commands) -- this provides dramatic performance improvments for
piped input to the shell, and if ast sfio is used, improvements for other 
commands too

for the test case on linux
        echo foo | od /dev/fd/0
the path /dev/fd/0 is a symlink to "socket:[<SOME-INTEGER>]"
but it seems to be informational only because attempts to open the read end 
fail with
        open("/dev/fd/0", O_RDONLY)       = -1 ENXIO (No such device or address)
in this case a simple dup(0) by the /dev/fd fs intercept would suffice
the process already has read access to fd 0 inherited across fork/exec
so its not clear why the system rejects the open()

the iffe tests
        src/lib/libast/features/lib
        src/cmd/ksh93/features/poll
check if the local system supports peek on pipes and if socketpair(AF_UNIX) can 
be used
in place of pipe()

_______________________________________________
ast-users mailing list
[email protected]
https://mailman.research.att.com/mailman/listinfo/ast-users

Reply via email to