Date: Sun, 23 Nov 1997 18:28:31 -0800 (PST) Message-Id: <199711240228.SAA02748@adit.ap.net> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" To: Indrek Mandre , djgpp AT delorie DOT com From: Nate Eldredge Subject: Re: Bug in djgpp? (fsext) Precedence: bulk At 12:25 11/23/1997 +0200, Indrek Mandre wrote: > >Hi! >I'v ran into strange bug with djgpp fsext. >When I alloc more than one descriptors then on the others the write >command doesn't work. >An example demonstrates it: > >#include >#include >#include > >int functions(__FSEXT_Fnumber func_number, int *rv, va_list args) >{ > printf ("Function: %d\n", func_number ); > > return 8; >} > >int main() >{ > int s1, s2; > char x[3]; > > s1 = __FSEXT_alloc_fd ( functions ); > s2 = __FSEXT_alloc_fd ( functions ); > >printf ("Reading 1:\n"); > read ( s1, x, 3 ); >printf ("Reading 2:\n"); > read ( s2, x, 3 ); >printf ("Writing 1:\n"); > write ( s1, "Hey", 3 ); >printf ("Writing 2:\n"); > write ( s2, "Hey", 3 ); > >return 0; >} > >Run it and see that read calls the function call, but write on second >descriptor doesn't. >Is it a bug in DJGPP or in me? >I am using win95 and DJGPP 2.01 on a pentium. This seems to be a bug in DJGPP, or at least a misdocumentation. I investigated it, and found the following: * The function `__FSEXT_alloc_fd' does not set the file handle flags. * `write' will only call the FSEXT function if the O_BINARY flag of the handle is set. I'm not sure whether either of these is correct. The default flags seem to vary between handles, causing different actions. As a workaround, you can call `setmode(fd,O_BINARY)' for each `fd' allocated by `__FSEXT_alloc_fd'. Nate Eldredge eldredge AT ap DOT net