delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2001/08/06/15:42:53

Date: Mon, 06 Aug 2001 21:44:49 +0300
From: "Eli Zaretskii" <eliz AT is DOT elta DOT co DOT il>
Sender: halo1 AT zahav DOT net DOT il
To: Sterten AT aol DOT com
Message-Id: <7263-Mon06Aug2001214448+0300-eliz@is.elta.co.il>
X-Mailer: Emacs 20.6 (via feedmail 8.3.emacs20_6 I) and Blat ver 1.8.9
CC: djgpp AT delorie DOT com
In-reply-to: <f5.d7a6d6a.28a021e1@aol.com> (Sterten@aol.com)
Subject: Re: files not closed after GPF
References: <f5 DOT d7a6d6a DOT 28a021e1 AT aol DOT com>
Reply-To: djgpp AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

> From: Sterten AT aol DOT com
> Date: Mon, 6 Aug 2001 12:37:53 EDT
> 
>  >This is done by design: trying to close a handle (or do something else
>  >that involves a system call) might as well do something nasty like
>  >some irrepairable damage to your disk.
> 
> I use ramdrive for such things 

A general-purpose library function cannot count on users doing that.

>  >A program that was hit by a GPF cannot be trusted!
> 
> then, what is the "protection" good for ?

Protection under DPMI has its limitations, but it's still better than
a real-mode program with no protection at all.  However, you must keep
in mind that all system calls still go through a real-mode, totally
unprotected DOS.

> But it's the same after crtl/break.

Also by design: Ctrl-BREAK is your way to stop a runaway program in
its tracks before it does any damage.  If you want the files closed
when you interrupt a program, use Ctrl-C.

> I never noticed such things before. Are unclosed files safe , or can
> they cause some other trouble ?

No, they never cause any trouble, because DOS cleans up (unless the
program wedges the machine).  You just have files that are truncated,
perhaps even zero-size.  But the filesystem is in a consistent state.

> But I'd prefer to modify gcc.exe or use a gcc-command-line-switch ,
> so it will create programs that close the files on error.

You can easily do this: define a signal handler for SIGINT, SIGSEGV,
SIGFPE, SIGQUIT, and any other signal you want, and make that signal
handler call the `exit' function.

- Raw text -


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