On Wed, Aug 06, 2014 at 09:03:22PM -0400, David Korn wrote:
> I have attached a different fix that doesn't have the problem the last one
> does.  However, if the last command in the pipeline is a shell built-in, it
> could hang for large output.
> 
> Let me know if this works for you.

It hangs as `cat' is a shell built-in in normal case:

 /usr/src/packages/BUILD/ksh93> ./arch/linux.i386-64/src/cmd/ksh93/ksh 
 /usr/src/packages/BUILD/ksh93> x=`cat ~/testfile.txt | cat -`
 Killed

whereas this one

 /usr/src/packages/BUILD/ksh93> x=`cat ~/testfile.txt | /bin/cat -`
 /usr/src/packages/BUILD/ksh93> 

does work ... IMHO both should work.  The test suite does survive with
this patch.

Werner

> 
> 
> 
> On Fri, Jul 25, 2014 at 4:04 AM, Dr. Werner Fink <[email protected]> wrote:
> 
> > On Thu, Jul 24, 2014 at 11:35:01AM -0400, David Korn wrote:
> > > I finally got a chance to look at this.
> > >
> > > The problem is that the standard is ambiguous about when a command
> > > substitution ends.
> > >
> > > The bourne shell used a pipe for command substitution and command
> > > substitution  terminated when the pipe closed.  Thus, if you had a command
> > > the wrote on standard output, forked and exited and the child wrote on 
> > > that
> > > pipe, the output from both processes was part of the command substitution.
> > >
> > > ksh considered the command substitution done when the command completed 
> > > and
> > > used memory for files less that 64K(IOBSIZE)  and this created a tmp file
> > > if it was larger.
> > >
> > > I tried to restore the old bourne shell semantics for `` so that the
> > > foreback test would work.  However, this caused the example you have to
> > > hang.  Here is a change which should fix this by using pipes for all `` 
> > > not
> > > just large ones.  Here is the one line patch:
> > >
> > > --- old/sh/subshell.c      Wed Apr  2 09:57:00 2014
> > > +++new/sh/subshell.c       Thu Jul 24 11:19:43 2014
> > > @@ -593,7 +574,7 @@
> > >                         sp->tmpfd = -1;
> > >                         sp->pipefd = -1;
> > >                         /* use sftmp() file for standard output */
> > > -                       if(!(iop = sftmp(comsub==1?PIPE_BUF:IOBSIZE)))
> > > +                       if(!(iop = sftmp(comsub==1?0:IOBSIZE)))
> > >                         {
> > >                                 sfswap(sp->saveout,sfstdout);
> > >
> > > errormsg(SH_DICT,ERROR_system(1),e_tmpcreate);
> > >
> > >
> > > Let me know.
> > >

-- 
  "Having a smoking section in a restaurant is like having
          a peeing section in a swimming pool." -- Edward Burr

Attachment: pgpBUl9DC9KFj.pgp
Description: PGP signature

_______________________________________________
ast-developers mailing list
[email protected]
http://lists.research.att.com/mailman/listinfo/ast-developers

Reply via email to