Hi,

On Tue, 13 Oct 1998 12:15:09 +0900, [EMAIL PROTECTED] (Masahiko
Shimoda) said:


> If the size of the file "sample.dat" was 65535 bytes and under,
> the program terminated with no errors. But the size was over
> 65535 bytes, the fwrite() call in the read_and_write() failed
> and "errno" was set to 512.

>         ##### Write error! ERROR No. : 512

Definitely reproduced under 2.0.35-pre15, although I haven't been able
to force it on 2.1.  

> Is there any improper part in this program?  Or, is there
> any other way to read from "stdout" asynchronously?

The only problem in your code is that it is doing something unusual:
there is no bug.  It seems that the buffered IO routines are generating
much larger IO requests than the kernel can deal with atomically.  If
you used unbuffered IO (read(2) and write(2) directly) and limited the
size of the IOs, you'd probably not see the problem (although it IS
still a kernel bug if the user's program ever gets this).

The offending syscall is write(2) to a unix domain socketpair, created
with socketpair( AF_UNIX, SOCK_STREAM...) and set to FASYNC, O_NDELAY.
Strace shows

        write(1, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 32918) = ? ERESTARTSYS

and this errno is picked up by the application.  There is a SIGIO
handler in effect, and a signal handler is delivered by the write, but
we are not inside the signal handler at the time of the write.

--Stephen
-
To unsubscribe from this list: send the line "unsubscribe linux-net" in
the body of a message to [EMAIL PROTECTED]

Reply via email to