More on pipes and O_NONBLOCK

Kandziora Jan jan.kandziora@siemens.com
Fri Aug 2 06:24:00 GMT 2002


Hi all,

It's been a while since I tried to use a cygwin pipe with nonblocking
operation.
I tried it with

	if (fcntl(0,F_SETFL,O_NONBLOCK)<0)
	{
		perror("input stream can not be set to nonblocking mode");
		exit(EXIT_FAILURE);
	}
	if (fcntl(1,F_SETFL,O_NONBLOCK)<0)
	{
		perror("output stream can not be set to nonblocking mode");
		exit(EXIT_FAILURE);
	}

It worked for reading from a piped stdin, but not for writing, although the
code
snipped above reported no error. Instead, the write on a piped stdout
blocked after
writing 12288 Bytes.

Now I read in a Win32 API Book that WIN32 APIs WriteFile() to any pipe is
always blocking. - Huh? -

If that's true, and Cygwin uses WIN32 API for Pipes, the second fcntl() has
to fail if the
descriptor belongs to a pipe, hasn't it? At least that behaviour should be
noted somewhere,
maybe in the "Implementation Details" section in the Cygwin API
Documentation.

What do you think?

	Jan

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/



More information about the Cygwin mailing list