delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/11/23/21:28:55

Date: Sun, 23 Nov 1997 18:28:31 -0800 (PST)
Message-Id: <199711240228.SAA02748@adit.ap.net>
Mime-Version: 1.0
To: Indrek Mandre <indrek AT warp DOT edu DOT ee>, djgpp AT delorie DOT com
From: Nate Eldredge <eldredge AT ap DOT net>
Subject: Re: Bug in djgpp? (fsext)

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 <stdio.h>
>#include <stdlib.h>
>#include <sys/fsext.h>
>
>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



- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019