delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2016/10/26/07:15:16

X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f
From: "Martin Str|mberg (ams AT ludd DOT luth DOT se) [via djgpp AT delorie DOT com]" <djgpp AT delorie DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: A grep 2.26 test fails because fopen sets errno to EACCES when openning an existing directory.
Date: Wed, 26 Oct 2016 10:52:08 +0000 (UTC)
Organization: Aioe.org NNTP Server
Lines: 56
Message-ID: <nuq1sm$1qnt$1@gioia.aioe.org>
References: <580BCAA5 DOT 2000304 AT gmx DOT de> <83d1irppmj DOT fsf AT gnu DOT org> <580D0638 DOT 8080605 AT gmx DOT de> <numomu$png$1 AT gioia DOT aioe DOT org> <580FC5AA DOT 5010009 AT gmx DOT de>
NNTP-Posting-Host: WLZdEp4S2PR09rkVF8ILdg.user.gioia.aioe.org
X-Complaints-To: abuse AT aioe DOT org
User-Agent: tin/2.2.1-20140504 ("Tober an Righ") (UNIX) (Linux/3.16.0-4-amd64 (x86_64))
X-Notice: Filtered by postfilter v. 0.8.2
Bytes: 3487
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

"Juan Manuel Guerrero (juan DOT guerrero AT gmx DOT de) [via djgpp AT delorie DOT com]" <djgpp AT delorie DOT com> wrote:
> IMHO, there is neither an error in grep nor in the testsuite.  They simple
> expect a posix comforming behavior of fopen and fread.  According to the
> man pages of my almost 10-year old linux box the following shall hold for
> a posix conforming fread (verbatim copy):

> RETURN VALUE
>        Upon  successful  completion,  fread() shall return the number of ele-
>        ments successfully read which is less than nitems only if a read error
>        or  end-of-file  is encountered. If size or nitems is 0, fread() shall
>        return 0 and the contents of the array and the  state  of  the  stream
>        remain unchanged. Otherwise, if a read error occurs, the error indica-
>        tor for the stream shall be set,  and errno shall be set  to  indicate
>        the error.

> I have also inspected http://pubs.opengroup.org/onlinepubs/009695399/functions/fread.html
> and it states the same.  Unfortunately nobody says what the errnos are.

Very weird. The ancient man page has it, But not the latest (and
neither at least some intermediate one as well as all man pages I've
seen don't mention errno).

As I understand your link above is POSIX.1-2004. It states that thee
are later version. Checking up on the latest leads to
<http://pubs.opengroup.org/onlinepubs/9699919799/functions/fread.html>
which is POSIX.1-2008 which states the same about errno.

Meanwhile the latest man page
(<http://man7.org/linux/man-pages/man3/fread.3.html>) says it's
POSIX.1-2008.

So now I think it's likely you've found a bug in the man page.

> But I fear that the issue is far more complicated.  The errno itself is not
> really important.  Important is the exit value of grep and this should be 2
> but it is 1 for the DJGPP port.  The test issues the following command:
>   ./grep -f a/ < /dev/null
> and a/ is an empty directory.  The directory is open using fopen and read
> using fread.  On linux and djgpp fread returns with a value of zero and the
> error status is indagated using ferror.

This ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

> The linux port returns with some error
> and terminates the program immediately with grep status = 2 meanwhile the djgpp
> port sees no error at all an continues running until it finishes with grep

and this ^^^^^^^^^^^^^^^^^^ sounds like they can't be true at the same
time. ???

> status = 1 making the check fail.  I still have not figured out what is going
> on here.  I will see how to fix all this.


-- 
MartinS

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019