m4-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] build: avoid test failure on HPUX


From: Eric Blake
Subject: Re: [PATCH] build: avoid test failure on HPUX
Date: Fri, 15 Mar 2013 16:31:46 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130219 Thunderbird/17.0.3

On 03/13/2013 08:47 PM, Gary V. Vaughan wrote:
> Hi Eric,
> 
> Thanks for working on this.
> 

>>
>> * doc/m4.texi (Command line files): Skip tests on systems where it
>> is impossible to start with stdin/out closed.
>> Reported by Gary V. Vaughan.
>>

> Not quite, the test is not skipped with your patch applied as is:
> 
>   hppa11.31% /bin/cat <&- 2>/dev/null
>   hppa11.31% echo $?
>   2

So the reopened stdin has properties that still make it unreadable.  Oh
well.

>   hppa11.11% /bin/cat <&- 2>/dev/null
>   hppa11.11% echo $?
>   0

Are you sure that transcript is right?  At any rate, all we are looking
for is some witness of whether the system reopens standard streams; it's
probably an all-or-none situation.

> 
> And yet, per my original report:
> 
>   hppa11.31% echo | /bin/cat >&- 2>/dev/null
>   hppa11.31% echo $?
>   0
>   hppa11.11% echo | /bin/cat >&- 2>/dev/null
>   hppa11.11% echo
>   1

Okay, then I'll use closed stdout as the witness, and push my modified
patch.  Thanks for testing.  In the meantime, I realized I have an
account on some HPUX machines (probably the same machines as you, now
that I recall who referred me access to those machines), and wrote a
little probe program to find out more:

#include <unistd.h>
int main(void) {
    int ret = 0;
    if (close(0))
        ret |= 1;
    if (close(1))
        ret |= 2;
    if (close(2))
        ret |= 4;
    return ret;
}

hppa11.11% ./foo; echo $?
0
hppa11.11% ./foo <&-; echo $?
1
hppa11.11% ./foo >&- 2>&-; echo $?
6

hppa11.23% ./foo; echo $?
0
hppa11.23% ./foo <&-; echo $?
0
hppa11.23% ./foo >&- 2>&-; echo $?
0

and another probe program:

#include <unistd.h>
#include <fcntl.h>
int main(void) {
    int ret = 0;
    int i;

    i = fcntl(0, F_GETFL);
    if (i >= 0) {
        switch (i & O_ACCMODE) {
        case O_RDONLY: ret |= 0001; break;
        case O_WRONLY: ret |= 0002; break;
        case O_RDWR:   ret |= 0003; break;
        }
    }
    i = fcntl(1, F_GETFL);
    if (i >= 0) {
        switch (i & O_ACCMODE) {
        case O_RDONLY: ret |= 0010; break;
        case O_WRONLY: ret |= 0020; break;
        case O_RDWR:   ret |= 0030; break;
        }
    }
    i = fcntl(2, F_GETFL);
    if (i >= 0) {
        switch (i & O_ACCMODE) {
        case O_RDONLY: ret |= 0100; break;
        case O_WRONLY: ret |= 0200; break;
        case O_RDWR:   ret |= 0300; break;
        }
    }
    return ret;
}

On Linux, where terminals are opened O_RDWR:

linux% ./foo; printf %o\\n $?
333
linux% ./foo </dev/null >/dev/null; printf %o\\n $?
321
linux% ./foo <&- >&-; printf %o\\n $?
300

and on HPUX:

hppa11.11% ./foo; printf %o\\n $?
333
hppa11.11% ./foo </dev/null >/dev/null; printf %o\\n $?
321
hppa11.11% ./foo <&- >&-; printf %o\\n $?
300

hppa11.23% ./foo; printf %o\\n $?
333
hppa11.23% ./foo </dev/null >/dev/null; printf %o\\n $?
321
hppa11.23% ./foo <&- >&-; printf %o\\n $?
322

Aha! it opens stdin as an O_WRONLY file, explaining why 'cat <&-' still
fails (it can't read an O_WRONLY file), but 'cat >&-' succeeds (an fd
was forced open).

> Taking into account the bizzare difference between stdin and stdout behaviour,

Not so bizarre once you understand my probes.

> this works for me:
> 
> syscmd(`echo|cat >&- 2>/dev/null')ifelse(sysval, `0',
>        `errprint(` skipping: system does not allow closing stdout
> ')m4exit(`77')')dnl

Yep, that's my plan.

> Of course this reveals some more gnulib testsuite failures on ia64*-hpux*, but
> that's another story... ;)

And one for gnulib to get involved with.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]