delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2002/01/10/23:00:06

X-Authentication-Warning: delorie.com: mailnull set sender to djgpp-workers-bounces using -f
From: sandmann AT clio DOT rice DOT edu (Charles Sandmann)
Message-Id: <10201110400.AA20996@clio.rice.edu>
Subject: frlist.c proposed patch
To: djgpp-workers AT delorie DOT com (DJGPP developers)
Date: Thu, 10 Jan 2002 22:00:01 -0600 (CST)
X-Mailer: ELM [version 2.5 PL2]
Mime-Version: 1.0
Reply-To: djgpp-workers AT delorie DOT com

This fixes the problem of incorrect flushing of a handle if the parent has
closed handle 3 or 4.  Test program _close(3); _close(4); system("test.exe");
The child opens a file writes and exits.  without patch it doesn't flush,
with patch it does.  This isn't a complete fix for all cases, but it 
does make sure we don't set up extra file structures which will be closed
that shouldn't.  

Should I use fileno() or hard code (efficiency vs data driven)
Should we invalidate the handle in the file structure if not open?


*** frlist.bak	Thu Jun  3 11:27:34 1999
--- frlist.c	Thu Jan 10 21:42:22 2002
***************
*** 1,6 ****
--- 1,7 ----
  /* Copyright (C) 1999 DJ Delorie, see COPYING.DJ for details */
  /* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
  #include <stdio.h>
+ #include <io.h>
  #include <libc/local.h>
  
  static __file_rec __initial_file_rec;
*************** void
*** 15,24 ****
  __setup_file_rec_list(void)
  {
    __initial_file_rec.next = 0;
!   __initial_file_rec.count = 5;
!   __initial_file_rec.files[0] = stdin;
!   __initial_file_rec.files[1] = stdout;
!   __initial_file_rec.files[2] = stderr;
!   __initial_file_rec.files[3] = stdprn;	/* in reverse order! (history) */
!   __initial_file_rec.files[4] = stdaux;
  }
--- 16,30 ----
  __setup_file_rec_list(void)
  {
    __initial_file_rec.next = 0;
!   __initial_file_rec.count = 0;
!   if(_get_dev_info(fileno(stdin)) != -1)
!     __initial_file_rec.files[__initial_file_rec.count++] = stdin;
!   if(_get_dev_info(fileno(stdout)) != -1)
!     __initial_file_rec.files[__initial_file_rec.count++] = stdout;
!   if(_get_dev_info(fileno(stderr)) != -1)
!     __initial_file_rec.files[__initial_file_rec.count++] = stderr;
!   if(_get_dev_info(fileno(stdprn)) != -1)     /* in reverse order! (history) */
!     __initial_file_rec.files[__initial_file_rec.count++] = stdprn;
!   if(_get_dev_info(fileno(stdaux)) != -1)
!     __initial_file_rec.files[__initial_file_rec.count++] = stdaux;
  }

- Raw text -


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