mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Rich Felker <dalias@libc.org>
To: Jonny Prouty <jonathanprouty@gmail.com>
Cc: musl@lists.openwall.com
Subject: Re: Unexpected behaviour writing to /dev/full
Date: Thu, 2 Aug 2018 15:51:36 -0400	[thread overview]
Message-ID: <20180802195136.GN1392@brightrain.aerifal.cx> (raw)
In-Reply-To: <CAEzKa92gpsx2PFVhQiwW3t-=0JaU9809wMCCqzFYxqVEhUoY6A@mail.gmail.com>

On Thu, Aug 02, 2018 at 02:53:26PM -0400, Jonny Prouty wrote:
> Or it could be that it is just extremely commonplace to NOT check whether
> you were able to successfully write to stdout before exiting. In which case
> you are absolutely correct, this would be a bug in busybox (and similar
> bugs in many other programs). I just tested both of the following commands
> on systems using musl, uclibc-ng, and glibc, all returned 0:
> 
> # bm's vim
> # vim --help &> /dev/full; echo $?
> 0
> 
> # gnu tar
> # tar --help &> /dev/full; echo $?
> 0
> 
> I'm leaning towards this is just the app didn't check whether their write
> to stdout was successful. Thanks for your help Rich.
> 
> 
> P.S. Please excuse my brevity, I am corresponding from my phone.
> 
> On Thu, Aug 2, 2018, 2:32 PM Jonny Prouty <jonathanprouty@gmail.com> wrote:
> 
> > I am indeed using busybox ls, but I can get similar behavior when running
> > things that aren't shell builtins.  For instance in Alpine if you run:
> >
> > # /bin/rc-status > /dev/full ; echo $?
> > 0
> >
> > or
> >
> > #/sbin/update-conf --help &> /dev/full ; echo $?
> > 0
> >
> > Some programs do behave as I'd expect, however
> >
> > # /sbin/apk --help> /dev/full ; echo $?
> > 1
> >
> > Something seems amiss.

What exit status the application wants to use is up to the
application, but as a matter of quality of design, it only makes sense
to return a failure exit code if the primary function the command was
supposed to perform did not work. Programs where the primary function
is their output, and the output is intended to be consumable/parsable
by other programs, should definitely exit with nonzero status if they
fail to write the full output, since bad things could happen if a
script acts on their incomplete output thinking it was complete and
correct. But there's really no good argument that failure to print a
usage message needs to be considered an error, and treating failure to
print unimportant status output as an error when the primary function
of the command already succeeded is probably a really bad idea.

In any case, libc has no control over the exit status; it's the
application's choice what to return.

Rich


      reply	other threads:[~2018-08-02 19:51 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-02 17:51 Jonny Prouty
2018-08-02 18:03 ` Rich Felker
2018-08-02 18:05   ` Rich Felker
2018-08-02 18:32     ` Jonny Prouty
2018-08-02 18:53       ` Jonny Prouty
2018-08-02 19:51         ` Rich Felker [this message]

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=20180802195136.GN1392@brightrain.aerifal.cx \
    --to=dalias@libc.org \
    --cc=jonathanprouty@gmail.com \
    --cc=musl@lists.openwall.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.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).