This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: 1.7.8: write fails with EAGAIN


Hi,

Hang on, you are saying that a *blocking* write(2) to a pipe returns
with EAGAIN?  Are you sure?  It would be quite a surprise if git would
actually do that.  EAGAIN is only an expected error for non-blocking
I/O, so applications which use blocking I/O usually only test for EINTR.

I checked out the winsup sources and built a cygwin1.dll for debugging (btw: Could you update the FAQ to state that gcc4 is required instead of gcc?).


What I found out:

In fhandler.cc, write_overlapped, there is the call to WriteFile:

	bool res = WriteFile (get_output_handle (), ptr, len, &nbytes,
			      get_overlapped ());

Surprisingly, this returns FALSE / nbytes = 0 / GetLastError = ERROR_INVALID_HANDLE on WinXP if the number of bytes exceeds some maximum and the handle refers to a pipe.
Since you don't know what kind of handle you're writing to in write_overlapped, it seems reasonable to do the write in chunks.


The first comment to WriteFile (http://msdn.microsoft.com/en-us/library/aa365747%28v=vs.85%29.aspx) suggests to limit the size to less than 32MB per write - although I didn't have this problem on X64.

-Robert

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]