All of lore.kernel.org
 help / color / mirror / Atom feed
From: Richard Hirst <rhirst@linuxcare.com>
To: Alan Modra <alan@linuxcare.com.au>
Cc: parisc-linux@lists.parisc-linux.org
Subject: Re: [parisc-linux] Re: pipes
Date: Mon, 26 Feb 2001 17:57:01 +0000	[thread overview]
Message-ID: <20010226175701.U4660@linuxcare.com> (raw)
In-Reply-To: <20010223212325.K4660@linuxcare.com>; from rhirst@linuxcare.com on Fri, Feb 23, 2001 at 09:23:25PM +0000

This is looking like a glibc/kernel issue regardling the width
of the type returned by lseek():


I have a simple way of reproducing the bug now:

merlin:/build# echo 'if ( test  -r /dev/null ); then echo TRUE; fi;
echo Oops' | /bin/sh
TRUE
merlin:/build#


The echo parameter is split over two lines there, and should result
in two lines of output 'TRUE' and then 'Oops'.

/bin/sh picks up input with one read of 57 characters, and then
processes the string, char by char, via input.c:buffered_getchar(),
until it has the complete if..then..fi\n (about 46 characters). Then it
tries to stuff input following the 'fi\n' back on to the input stream by
doing an lseek(fd, -n, SEEK_CUR), before forking a child to do the
'test'.  On return from the child, it expects to pick up the input it
stuffed back on to the input stream.

The problem is that the input stream is a pipe, and lseek doesn't work.
bash should have decided that its input stream was not seekable and
dropped back to multiple reads of one byte.  It uses this test:

#  define fd_is_seekable(fd) (lseek ((fd), 0L, SEEK_CUR) >= 0)

and then

  if (fd_is_seekable (fd) == 0)
    size = 1;
  else
    size = (size_t)((sb.st_size > MAX_INPUT_BUFFER_SIZE) ? ...


Now for us lseek is of type __off64_t (from /usr/include/unistd.h),
although our kernel has sys_lseek() returning off_t, which is 32
bits.  Anyway, if I try to print the 64 bit return value from lseek()
I get 0x00000000ffffffe3.  The lower 32 bits is -ESPIPE, which is the
expected errno.  I don't know if glibc, kernel, or both are at fault
here.

Richard
 

  reply	other threads:[~2001-02-26 17:56 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20010223113052.G4660@linuxcare.com>
     [not found] ` <Pine.LNX.4.21.0102232231470.9345-100000@front.linuxcare.com.au>
2001-02-23 21:23   ` [parisc-linux] Re: pipes Richard Hirst
2001-02-26 17:57     ` Richard Hirst [this message]
2001-02-26 21:30       ` Matthew Wilcox
2001-03-07 17:39       ` [parisc-linux] INLINE_SYSCALL/gcc-bug? (Was Re: pipes) Paul Bame
2001-03-07 17:57         ` Paul Bame
2001-03-07 18:10         ` Jason Eckhardt
2001-03-07 18:11         ` John David Anglin
2001-02-09 15:29 [parisc-linux] pipes Alan Modra
2001-02-22  6:37 ` [parisc-linux] pipes Alan Modra
2001-02-22 10:37   ` Jes Sorensen
2001-02-22 11:00   ` Richard Hirst
2001-02-22 11:09     ` Richard Hirst
2001-02-22 11:26       ` Alan Cox
2001-02-22 11:39         ` Alan Modra
2001-02-22 11:52           ` Alan Cox
2001-02-22 11:53           ` Richard Hirst
2001-02-22 11:34     ` Alan Modra
2001-02-22 11:52       ` Richard Hirst
2001-02-22 12:27         ` Alan Modra
2001-02-22 13:03           ` Richard Hirst
2001-02-22 13:27             ` Alan Modra
2001-02-22 17:00               ` Richard Hirst
2001-02-22 17:44                 ` Paul Bame
2001-02-23 12:25                   ` Richard Hirst
2001-02-23 12:43                     ` Alan Modra

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20010226175701.U4660@linuxcare.com \
    --to=rhirst@linuxcare.com \
    --cc=alan@linuxcare.com.au \
    --cc=parisc-linux@lists.parisc-linux.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.