Path: utzoo!utgpu!water!watmath!clyde!ima!bbn!diamond.bbn.com!mlandau From: mlandau@bbn.com (Matt Landau) Newsgroups: comp.lang.c Subject: Re: system Keywords: fork and wait not for MSDOS Message-ID: <10491@jade.BBN.COM> Date: 25 Jan 88 05:04:30 GMT References: <127@dcrbg1.UUCP> <452@picuxa.UUCP> <3920@sigi.Colorado.EDU> <1317@laidbak.UUCP> <10202@ut-sally.UUCP> Reply-To: mlandau@bbn.com (Matt Landau) Organization: BBN Laboratories Incorporated, Cambridge, MA Lines: 22 In comp.lang.c (<10202@ut-sally.UUCP>), nather@ut-sally.UUCP (Ed Nather) writes: >MS-DOS can do the same thing (create a new process and wait for it to >finish) -- it's called "spawn()". Look for it in your favorite manual. The fundamental difference between Unix fork() and creation of child processes in MS-DOS is twofold: (1) When a child is created by fork(), both child and parent continue to run, unless the parent explicitly calls wait() to wait for the child to terminate. MS-DOS is single-tasking, so creation of a child process normally involves suspending the parent (but there are ways you can get around this and fake multitasking). (2) More importantly, fork() creates a child process by *copying the parent's address space* -- the child is an exact copy of the parent until they take divergent execution paths. The child process is typically overlaid almost immediately by a call to exec(), but this is by no means required. MS-DOS has no way to copy a process's address space. -- Matt Landau Waiting for a flash of enlightenment mlandau@bbn.com in all this blood and thunder