This is the mail archive of the
cygwin@cygwin.com
mailing list for the Cygwin project.
Re: 1.3.5: write(2) system call fails with 0 length
- To: rreitz at mssinternet dot com
- Subject: Re: 1.3.5: write(2) system call fails with 0 length
- From: Shun-ichi GOTO <gotoh at taiyo dot co dot jp>
- Date: Wed, 14 Nov 2001 13:53:53 +0900 (JST)
- Cc: cygwin at cygwin dot com
- References: <5.1.0.14.2.20011113215143.03327810@pop.mssinternet.com>
>>>>> 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/