DASH Shell discussions
 help / color / mirror / Atom feed
From: Jilles Tjoelker <jilles@stack.nl>
To: Steve Schnepp <steve.schnepp@gmail.com>
Cc: dash@vger.kernel.org, 595063@bugs.debian.org
Subject: Re: read() builtin doesn't read integer value /proc files (but bash's does)
Date: Thu, 2 Sep 2010 21:09:47 +0200	[thread overview]
Message-ID: <20100902190947.GA66603@stack.nl> (raw)
In-Reply-To: <AANLkTinTd+29=8EkiTKptoE8nnVphcQ_TW=ezS99LmWw@mail.gmail.com>

On Wed, Sep 01, 2010 at 10:10:11AM +0200, Steve Schnepp wrote:
> Hi, I opened bug 595063 on the debian BTS [1] and I was suggested to
> resend the email upstream.

> So I copied the body of the bug below :

> dash's read() builtin seems to read the underlying file 1 char at a
> time. This doesn't work with some files under /proc, since procfs isn't
> fully POSIX compliant.

> [snip]

> After a little digging, it only appears on files that contains just an
> integer value. When asked to read with a non-null offset (*ppos != 0),
> __do_proc_dointvec() just returns 0 (meaning an EOF) as shown on [2].

> I'm aware that the issue isn't strictly a dash one, since it has the
> right to read one character at a time. But since fixing procfs to be
> conforming to POSIX isn't a realistic option, would it be possible to
> have a workaround that doesn't involve an external tool like cat(1) ?

Given that other files in /proc do work, I don't see why the ones that
only contain an integer value cannot be fixed. All the necessary state
to produce the second and further bytes is available.

Choosing a powerful abstraction like a regular file has its
implications.

Note that a change in the file between the single-byte reads will cause
an inconsistent value to be read. This is also the case with regular
files on a filesystem, so it is acceptable.

If single-byte reads are really unacceptable, then the proper way to
read these files needs to be documented, and clear violations that will
not work properly should cause an error (in this case, this means that
reading one byte from offset 0 should fail like reading one byte from
offset 1 does).

-- 
Jilles Tjoelker

  parent reply	other threads:[~2010-09-02 19:09 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-09-01  8:10 read() builtin doesn't read integer value /proc files (but bash's does) Steve Schnepp
2010-09-02 15:02 ` Steve Schnepp
2010-09-03 21:25   ` Jilles Tjoelker
2010-09-04 18:20     ` Steve Schnepp
2010-09-04 19:35       ` Jilles Tjoelker
2010-11-28  8:42         ` Herbert Xu
2010-12-15  9:49           ` read() builtin doesnt read integer value /proc files (but bashs does) Cristian Ionescu-Idbohrn
2010-12-15 18:55             ` Jonathan Nieder
2010-12-15 19:12               ` Cristian Ionescu-Idbohrn
2010-12-18 22:23               ` Jilles Tjoelker
2010-09-02 19:09 ` Jilles Tjoelker [this message]
2010-09-03  9:23   ` read() builtin doesn't read integer value /proc files (but bash's does) Steve Schnepp

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=20100902190947.GA66603@stack.nl \
    --to=jilles@stack.nl \
    --cc=595063@bugs.debian.org \
    --cc=dash@vger.kernel.org \
    --cc=steve.schnepp@gmail.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox