www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/08/18/18:43:52

From: "Campbell, Rolf [SKY:1U32:EXCH]" <cp1v45 AT americasm01 DOT nt DOT com>
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
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



- Raw text -


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