Path: utzoo!attcan!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!zaphod.mps.ohio-state.edu!julius.cs.uiuc.edu!apple!portal!cup.portal.com!ekalenda From: ekalenda@cup.portal.com (Edward John Kalenda) Newsgroups: comp.os.msdos.programmer Subject: Re: Child processes in Mess-Dos Message-ID: <34596@cup.portal.com> Date: 6 Oct 90 19:34:57 GMT References: <619@demott.COM> <15651@yunexus.YorkU.CA> <4469@bwdls58.UUCP> <1990Oct5.170852.29736@sea.com> <2555@gmuvax2.gmu.edu> Organization: The Portal System (TM) Lines: 27 In article <1990Oct5.170852.29736@sea.com> keck@sea.com (John Keck) writes: >Seems to me I read somewhere the EXE loader is part of COMMAND.COM. So >perhaps the distinction is whether the child is COM or EXE file. COMMAND.COM is actually two pieces. The resident portion has all the tables and code needed by other programs. The transient portion has the command line interpreter and the builtin DOS commands (copy, dir, etc.). DOS itself does the load and executee of both .COM and .EXE files. When COMMAND.COM executes a program, the transient portion relocates itself into high memory, freeing the memory it was in, and executes INT 21h function 0. When the program returns, the transient portion is reloaded by the resident portion, which is why you must have the COMMAND.COM you booted from available when your program exits. Since the program loader is part of DOS, the spawn() and exec() functions in C don't deal with COMMAND.COM at all. In fact, the system() function just uses spawn() with COMMAND.COM as the program to have DOS exec. So, if you know the path to the executable and don't need to redirect stdin or stdout, you can save memory by using spawn(). There are even variants in the library which will search the PATH environmental variable for you. The only reason to ever use system() is if you need redirection (and don't want to hassle it yourself) or you are trying to use a command built into COMMAND.COM or execute a batch file. Ed ekalenda@cup.portal.com