Subject: Re: 1.3.5: write(2) system call fails with 0 length
From: Shun-ichi GOTO <[email-masked]>
To: [email-masked]
Cc: [email-masked]
Date: Wed, 14 Nov 2001 13:53:53 +0900 (JST)

>>>>> at Tue, 13 Nov 2001 21:58:32 -0600
>>>>> Randy Reitz <[email-masked]> 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  <[email-masked]>
   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/