www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/05/01/13:30:50

Date: Thu, 1 May 1997 20:08:20 +0300 (IDT)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
To: Paul Campisi <pcampisi AT ececs DOT uc DOT edu>
cc: djgpp AT delorie DOT com
Subject: Re: System command
In-Reply-To: <199705011631.MAA08470@banana.ece.uc.edu>
Message-ID: <Pine.SUN.3.91.970501195543.4436D-100000@is>
MIME-Version: 1.0

On Thu, 1 May 1997, Paul Campisi wrote:

> 	I have a question about the System command. Whenever I call
> it and the file IS NOT an executable the whole program crashes. I know,
> you aren't supposed to be trying to execute the file in the first place,
> but isn't there a way to TRAP the error and not cause a crash if the 
> program is not an executable? COMMAND.COM doesn't crash if you try
> to run CONFIG.SYS!

This is a DOS problem, not DJGPP's.  When `system' tells DOS to run 
CONFIG.SYS or any other non-executable file, DOS checks to see if it has 
an MZ signature (meaning it's a .exe program) and if not, blindly assumes 
that it is a .com executable, loads it and lets it "run", with quite
predictable results.

Btw, in my experience, COMMAND.COM could also crash that way.  It depends 
on the file you try to execute, and even with CONFIG.SYS, it depends on 
what is its the content of.

`system' could of course test the program it is invoking for being an 
excutable, but then it might refuse to run some rarely-used types of 
executable files about which it doesn't know, because testing files for 
being an executable is not easy at all.  Try writing a program that does 
that and see for yourself.

- Raw text -


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