Mail Archives: djgpp/2001/08/06/15:42:53
> 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 -