This is the mail archive of the cygwin@cygwin.com 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.3.5: write(2) system call fails with 0 length



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


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