From: "Campbell, Rolf [SKY:1U32:EXCH]" Newsgroups: comp.os.msdos.djgpp Subject: Re: What's the difference between system, spawn and exec? Date: Wed, 18 Aug 1999 11:47:58 -0400 Organization: Nortel Networks Lines: 18 Message-ID: <37BAD5AE.A01B904F@americasm01.nt.com> References: <7pdhog$glp$1 AT server DOT noris DOT net> NNTP-Posting-Host: bmerhc00.ca.nortel.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Mailer: Mozilla 4.7 [en] (X11; I; HP-UX B.10.20 9000/712) X-Accept-Language: en To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com Goh Yong Kwang wrote: > The functions, system(), spawn() and exec() are used to execute other programs > or commands. So what's the difference between them? > > When should I use system(), spawn() and exec()? You should only use 'exec' when you are writing a program for UNIX, and it is only in DJGPP for the purpose of compatability. 'spawn' runs an external program and waits for it to exit before returning control to your program. 'system' runs a command-line in new shell, so you could do stuff like system("dir") but you couldn't do spawn("dir") becaue 'dir' is a shell command and not a program. -- -Rolf Campbell (39)3-6318