Mailing-List: contact cygwin-help@sourceware.cygnus.com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe@sources.redhat.com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin@sources.redhat.com>
List-Help: <mailto:cygwin-help@sources.redhat.com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner@sources.redhat.com
Delivered-To: mailing list cygwin@sources.redhat.com
Date: Wed, 14 Nov 2001 13:53:53 +0900 (JST)
Message-Id: <20011114.135353.111406103.gotoh@taiyo.co.jp>
To: rreitz@mssinternet.com
Cc: cygwin@cygwin.com
Subject: Re: 1.3.5: write(2) system call fails with 0 length
From: Shun-ichi GOTO <gotoh@taiyo.co.jp>
In-Reply-To: <5.1.0.14.2.20011113215143.03327810@pop.mssinternet.com>
References: <5.1.0.14.2.20011113215143.03327810@pop.mssinternet.com>
X-Mailer: Mew version 2.1 on Emacs 20.7 / Mule 4.1 (AOI)
X-Cite-Me: =?iso-2022-jp?B?GyRCOGUbKEI=?=
Mime-Version: 1.0
Content-Type: Text/Plain; charset=us-ascii
Content-Transfer-Encoding: 7bit


>>>>> at Tue, 13 Nov 2001 21:58:32 -0600
>>>>> Randy Reitz <rreitz@mssinternet.com> said,> 

> Here is a test program....

It's strange test.
Do like this, and get result: "2nd write() failed: Bad address".
So you should give valid pointer as 2nd argument of 2nd write() call.
for example, write (fd, buf, 0);

main()
{
         int fd, ret;
         char * buf[4];
         buf[0] = buf[1] = buf[2] = buf[3] = '0';
         fd = open( "foo", O_RDWR|O_CREAT );  /* O_CREATE required */
	 if (fd < 0) {
	     perror("open() failed");
	     exit(1);
	 }
         ret = write( fd, (char *) buf, 4);
	 if (ret < 0) {
	     perror("1st write() failed");
	     exit(2);
	 }
         ret = write( fd, (char *)0, 0);       /* NULL ptr is not allowed */
	 if (ret < 0) {
	     perror("2nd write() failed");
	     exit(3);
	 }
         printf("ret=%d, errno=%d\n", ret, errno);
         close( fd );
}


--- Regards,
 Shun-ichi Goto  <gotoh@taiyo.co.jp>
   R&D Group, TAIYO Corp., Tokyo, JAPAN

--
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/

