Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watnot!watmath!clyde!rutgers!mit-eddie!bu-cs!bucsb.bu.edu!madd From: madd@bucsb.bu.edu.UUCP Newsgroups: comp.lang.c Subject: Re: Fork and Exec Message-ID: <889@bucsb.bu.edu.UUCP> Date: Wed, 1-Apr-87 22:40:25 EST Article-I.D.: bucsb.889 Posted: Wed Apr 1 22:40:25 1987 Date-Received: Sat, 4-Apr-87 10:27:19 EST References: <6635@brl-adm.ARPA> Reply-To: madd@bucsb.bu.edu.UUCP (Jim "Jack" Frost) Organization: ODO (Organization for the Disorganization of Organization) Lines: 31 In article <6635@brl-adm.ARPA> bagpiper@csvax.caltech.edu writes: > What is the difference between fork and exec in a unix environment and > furthermore how does that map into a MS-Dos environment?? No problem. fork() causes program execution to split into two identical processes. They have independent data sections (although the two are identical to begin with) and may have shared code, although on some systems it is easier to duplicate the code than to share it. exec() is slightly different. It means to load in a new program ON TOP OF the current one. Thus to run a program and return, you would fork(), then have the child process of the fork perform an exec(). When the new program exits, the program that executed the fork() will be notified. Usually this parent sits in a wait state, although not always. MS-DOS is a bit different. Because it's not multitasking, the concept of fork() is impossible. Instead, there exists an exec function that performs the functions of ALL THREE of the unix functions fork(), exec() and wait(). When you call exec, MS-DOS loads the new program into a new space, and gives it control. When it terminates, control is returned to the parent process. This is much more primitive than in unix. I hope this is helpful. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Jim Frost * The Madd Hacker | UUCP: ..!harvard!bu-cs!bucsb!madd H H | ARPA: madd@bucsb.bu.edu H-C-C-OH <- heehee +---------+---------------------------------- H H | "We are strangers in a world we never made"