Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe@cygwin.com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin@cygwin.com>
List-Help: <mailto:cygwin-help@cygwin.com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner@cygwin.com
Mail-Followup-To: cygwin@cygwin.com
Delivered-To: mailing list cygwin@cygwin.com
Reply-To: <manav.ahuja@wipro.com>
From: "Manav Ahuja" <manav.ahuja@wipro.com>
To: <cygwin@cygwin.com>
Subject: Can u help me how to unsubscribe
Date: Fri, 26 Jul 2002 16:55:19 +0530
Organization: Wipro Technologies
Message-ID: <002901c23497$216ea2c0$daaba8c0@wipro.com>
MIME-Version: 1.0
Content-Type: multipart/mixed;
	boundary="----=_NextPartTM-000-86770c25-e047-4103-9d99-d48f476189db"
X-Priority: 3 (Normal)
X-MSMail-Priority: Normal
Importance: Normal
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4522.1200
In-Reply-To: <F536EC3453B2D411AD6100508BAF5F9901FAB48E@bwga521a.ts.siemens.de>

------=_NextPartTM-000-86770c25-e047-4103-9d99-d48f476189db
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: 7bit

i want unsubsribe from the list ...

plz can anybody help

Manav

-----Original Message-----
From: cygwin-owner@cygwin.com [mailto:cygwin-owner@cygwin.com] On Behalf
Of Kandziora Jan
Sent: Friday, July 26, 2002 4:47 PM
To: 'cygwin@cygwin.com'
Subject: piped stdout and O_NONBLOCK

Hi all,

In short: Does it work?
I wanted a program to write its debug messages to a pipe, data flowing
into "faucet" of "netpipes" and over a network connection.
But that did not work, because faucet blocks on a connect() from the
other side and meanwhile does not read any data from the pipe. So the
first program blocks in writing its output after a while, even if the
output stream is set to O_NONBLOCK.

For testing purposes I wrote a program "blocktest":

#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/select.h>
#include <unistd.h>

int main(void)
{
	char    buffer[4096];
	fd_set  input_set;
	int     read_bytes;
	int     remaining_bytes;
	char   *p;
	int     written_bytes;

	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);
	}

	FD_ZERO(&input_set);
	FD_SET(0,&input_set);

	for(;;)
	{
		// Try to read.
		if ((read_bytes=read(0,&buffer,sizeof(buffer)))<0)
		{
			if (errno!=EAGAIN)
			{
				perror("read failed");
				exit(EXIT_FAILURE);
			}
		}
		else
		{
			// Nothing to read. Try to write.
			remaining_bytes=read_bytes;
			p=(char*)&buffer;
			while (remaining_bytes>0)
			{
				if
((written_bytes=write(1,&p,remaining_bytes))<0)
				{
					if (errno==EAGAIN) break;

					perror("write failed");
					exit(EXIT_FAILURE);
				}
				remaining_bytes-=written_bytes;
				p+=written_bytes;
			}			

			// Write would block. Wait for new data to read.
			select(1,&input_set,NULL,NULL,NULL);
		}
	}
}

Then I put it into a pipeline

cat /dev/zero | ./blocktest | sleep 1000

With Linux this works as expected, with a "cat" using nearly all cpu
time.
With Cygwin, "blocktest" blocks in the write call after writing 12288
bytes,
causing "cat" to block.
I tested this with Cygwin-1.3.9 and 1.3.12-2.

Did I miss something?

	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/


------=_NextPartTM-000-86770c25-e047-4103-9d99-d48f476189db
Content-Type: text/plain;
	name="Wipro_Disclaimer.txt"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
	filename="Wipro_Disclaimer.txt"

**************************Disclaimer************************************

Information contained in this E-MAIL being proprietary to Wipro Limited is 
'privileged' and 'confidential' and intended for use only by the individual
 or entity to which it is addressed. You are notified that any use, copying 
or dissemination of the information contained in the E-MAIL in any manner 
whatsoever is strictly prohibited.

***************************************************************************


------=_NextPartTM-000-86770c25-e047-4103-9d99-d48f476189db
Content-Type: text/plain; charset=us-ascii

--
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/
------=_NextPartTM-000-86770c25-e047-4103-9d99-d48f476189db--
