> 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

I have written an efficient binary data file archiver in ksh93, thanks to 
this design.
Here is a simplified description of the archive format and extraction 
algorithm:

while read namelen datalen      # read one line ASCII header describing an 
entry
do
        file="$(head -c $namelen)"      # read file name (that may contain 
newline)
        head -c $datalen >$file # copy binary data from stdin to file 
done

This works nicely with ksh93, even when archive data is piped to stdin.
With most other shells, this code fails because 'read' consumes data 
intended for 'head'.

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

Reply via email to