[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Diffutils-devel] diffutils-3.6.17-d5ba on HP-UX
From: |
Jim Meyering |
Subject: |
Re: [Diffutils-devel] diffutils-3.6.17-d5ba on HP-UX |
Date: |
Sun, 30 Dec 2018 14:51:36 -0800 |
On Sun, Dec 30, 2018 at 1:32 PM Jim Meyering <address@hidden> wrote:
>
> On Sun, Dec 30, 2018 at 10:26 AM Bruno Haible <address@hidden> wrote:
> ...
> > The test scenario I used on Linux and HP-UX is:
> > - Preparation:
> > $ cd tests
> > $ echo a > a
> > - Command:
> > $ ../src/diff -N - a <&-
> >
> > Result on HP-UX:
> > $ ../src/diff -N - a <&-
> > diff: -: Bad file number
> >
> > Result on Linux:
> > $ ../src/diff -N - a <&-
> > 0a1
> > > a
> ...
> >
> > On HP-UX:
> >
> > $ tusc ../src/diff -N - a <&-
> > execve("../src/diff", 0x87fffffffffffb08, 0x87fffffffffffb30) = 0 [64-bit]
> > ...
> > ioctl(0, TCGETA, 0x87fffffffffff3e0) ..................... ERR#25 ENOTTY
> > fstat(0, 0x87fffffffffff420) ............................. = 0
> ...
> >
> > On Linux:
> >
> > $ strace ../src/diff -N - a <&-
> > execve("../src/diff", ["../src/diff", "-N", "-", "a"], [/* 78 vars */]) = 0
> > ...
> > ioctl(0, TCGETS, 0x7ffd75318810) = -1 EBADF (Bad file descriptor)
> > fstat(0, 0x7ffd75318940) = -1 EBADF (Bad file descriptor)
> ...
> >
> > The crucial difference is the open("a", O_RDONLY...) call, which is meant
>
> Hi Bruno,
> Thanks for all of that analysis.
>
> The crucial difference seems earlier than that. HP-UX's fstat
> erroneously returns 0 for the invalid (closed) stdin file descriptor,
> while Linux's returns EBADF.
>
> GNU diff explicitly handles the case of a closed file descriptor (note
> the test for errno == EBADF in diff.c). That test cannot do its job
> when fstat is not POSIX-conforming. NEWS from diffutils-3.3 says this:
>
> --new-file (-N) and --unidirectional-new-file now allow comparisons to "-".
> A standard input that's closed acts like a nonexistent file.
>
> One way to work around that HP-UX flaw is to make gnulib's fstat
> replacement return EBADF when the return value would otherwise be 0,
> yet fcntl (fd, F_GETFD) returns -1.
To confirm whether the proposed workaround is feasible, would you
please tell me what this prints on that HP-UX system?
printf '%s\n' '#include <unistd.h>' '#include <fcntl.h>' \
'int main() { return 1 + fcntl (0, F_GETFD);}' > k.c \
&& gcc k.c && ./a.out <&-; echo $?
- Re: [Diffutils-devel] diffutils-3.6.17-d5ba on Mac OS X 10.4, (continued)
- Re: [Diffutils-devel] diffutils-3.6.17-d5ba on Mac OS X 10.4, Bruno Haible, 2018/12/28
- Re: [Diffutils-devel] diffutils-3.6.17-d5ba on HP-UX, Bruno Haible, 2018/12/28
- Re: [Diffutils-devel] diffutils-3.6.17-d5ba on HP-UX, Bruno Haible, 2018/12/28
- Re: [Diffutils-devel] diffutils-3.6.17-d5ba on HP-UX, Jim Meyering, 2018/12/28
- Re: [Diffutils-devel] diffutils-3.6.17-d5ba on HP-UX, Bruno Haible, 2018/12/29
- Re: [Diffutils-devel] diffutils-3.6.17-d5ba on HP-UX, Jim Meyering, 2018/12/29
- Re: [Diffutils-devel] diffutils-3.6.17-d5ba on HP-UX, Bruno Haible, 2018/12/29
- Re: [Diffutils-devel] diffutils-3.6.17-d5ba on HP-UX, Jim Meyering, 2018/12/30
- Re: [Diffutils-devel] diffutils-3.6.17-d5ba on HP-UX, Bruno Haible, 2018/12/30
- Re: [Diffutils-devel] diffutils-3.6.17-d5ba on HP-UX, Jim Meyering, 2018/12/30
- Re: [Diffutils-devel] diffutils-3.6.17-d5ba on HP-UX,
Jim Meyering <=
- Re: [Diffutils-devel] diffutils-3.6.17-d5ba on HP-UX, Bruno Haible, 2018/12/31
Re: [Diffutils-devel] [platform-testers] new snapshot available: diffutils-3.6.17-d5ba, Bruno Haible, 2018/12/28
Re: [Diffutils-devel] diffutils-3.6.17-d5ba on AIX 7, Bruno Haible, 2018/12/28