gnu-arch-users
[Top][All Lists]
Advanced

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

Re: [Gnu-arch-users] Re: tla on aix


From: Tom Lord
Subject: Re: [Gnu-arch-users] Re: tla on aix
Date: Tue, 10 Feb 2004 14:53:58 -0800 (PST)

    > From: address@hidden

    > Bizarrely, the problem appears to be in write()ing out a zero-length
    > buffer. The following program fails in precisely the same fashion.

    > #include <stdio.h>
    > int main(void)
    > {
    >         ssize_t rv;
    >         char buf[4]="hih";
    >         rv = write(2, buf, 0);
    >         printf("rv %i\n", rv);
    >         return 1;
    > }

    > If the length is any non-positive number, this program runs happily; for
    > length=zero, no output is produced, and it hangs.

    > Is this some weird corner of the C standard, or is AIX being
    > pathologically odd?

Posix says:

        If 'nbytes' is zero and the file is a regular file, the
        `write()' function shall return zero and have no other
        results.  If `nbyte' is zero and the file is not a regular
        file, the results are unspecified. 

This apparently relates to the rationale:

        Also, some existing systems (*e.g., Eigth Edition) permit a
        write of zero bytes to mean that the reader should get an
        end-of-file indication;  for those systems, a return value of
        zero from `write()' indicates a successful write of an
        end-of-file indication.  

And, of course, usually stderr is not a regular file.   I don't know
off the top of my head whether it is or not as invoked from the test
script -- and I don't much care.

So:

Yes, AIX is being pathologically, idiotically odd.  While hanging the
process is, I suppose, conformant with a requirement that the behavior
is "unspecified" --- well, I guess I have nothing nice to say about
AIX in this area.

To check that your diagnosis is correct, could you please modify the
function: ./src/hackerlab/vu/vu-sys.c(vu_sys_write) to check if the
parameter `count' is 0 and, if so, return 0 rather than calling
`write()'?   If that fixes the problem, I'll be happy to add that
change to libhackerlab.

-t






reply via email to

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