From: Eduardo Bustamante <dualbus@gmail.com>
To: Denys Vlasenko <vda.linux@googlemail.com>
Cc: Herbert Xu <herbert@gondor.apana.org.au>, dash@vger.kernel.org
Subject: Re: Bug? "fstat64(f, &sb) < 0 && S_ISREG(sb.st_mode)"
Date: Tue, 25 Oct 2016 12:13:51 -0500 [thread overview]
Message-ID: <CAOSMAutbPNXKy_GVHDWiJv8=LRDnMPNBrsN1RgwYGVL4gJTwmg@mail.gmail.com> (raw)
In-Reply-To: <CAK1hOcMV9YoUNDC_spEawpfFf9hcYdOd-BiF_7rm0CFJ0ZyLaQ@mail.gmail.com>
I see the change was introduced here
http://git.kernel.org/cgit/utils/dash/dash.git/commit/?id=f78674ed6f95b594dcac0e96d6a76c5f64aa2cbf,
by importing code from FreeBSD's sh.
What I find interesting is testing the contents of 'sb', when the
fstat64 call failed. FreeBSD's code has the opposite:
https://github.com/freebsd/freebsd/blob/master/bin/sh/redir.c#L200,
i.e. they do:
if (fstat(f, &sb) != -1 && S_ISREG(sb.st_mode)) {
BTW, that code was introduced here:
https://github.com/freebsd/freebsd/commit/e3cb9d1015e8283f4f9d116cf50f510741f8c0dd
Also, the way the open is performed has an interesting consequence,
i.e. the redirection operation on a FIFO blocks until something is
written to the FIFO:
hp% dash -Cc 'rm ff; mkfifo ff; echo a > ff'
^Cdash: 1: cannot create ff: Interrupted system call
It seems to be the same case for mksh, ksh93, posh, pdksh. Not that it
matters though.
next prev parent reply other threads:[~2016-10-25 17:14 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-25 15:33 Bug? "fstat64(f, &sb) < 0 && S_ISREG(sb.st_mode)" Denys Vlasenko
2016-10-25 17:13 ` Eduardo Bustamante [this message]
2016-10-25 17:19 ` Eduardo Bustamante
2016-10-26 21:43 ` Jilles Tjoelker
2016-10-27 0:35 ` Eduardo Bustamante
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='CAOSMAutbPNXKy_GVHDWiJv8=LRDnMPNBrsN1RgwYGVL4gJTwmg@mail.gmail.com' \
--to=dualbus@gmail.com \
--cc=dash@vger.kernel.org \
--cc=herbert@gondor.apana.org.au \
--cc=vda.linux@googlemail.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;
as well as URLs for NNTP newsgroup(s).