Path: utzoo!utgpu!news-server.csri.toronto.edu!clyde.concordia.ca!uunet!virtech!cpcahil From: cpcahil@virtech.uucp (Conor P. Cahill) Newsgroups: comp.unix.questions Subject: Re: mv'ing files from a C program Message-ID: <1990Nov16.231909.20173@virtech.uucp> Date: 16 Nov 90 23:19:09 GMT References: <22@mixcom.UUCP> <1990Nov15.132952.11932@virtech.uucp> <1990Nov15.183359.963@ssd.kodak.com> Reply-To: cpcahil@virtech.UUCP (Conor P. Cahill) Distribution: na Organization: Virtual Technologies Inc., Sterling VA Lines: 27 In article <1990Nov15.183359.963@ssd.kodak.com> weimer@ssd.kodak.com (Gary Weimer) writes: >In article <1990Nov15.132952.11932@virtech.uucp> cpcahil@virtech.UUCP (Conor P. Cahill) writes: >>You don't have to use system(3), you can use fork/execl(2) (or one of it's >>family of functions) as follows: >> >> if( fork() == 0 ) >> execl("/bin/mv","mv",oldfile,newfile,(char *)0); >> else >> wait((int *)0); > >That's just about exactly what system(3) does. (i.e. you gain nothing for >all the added code) No. System(3) does something like the following: (with error checking removed) if( fork() == 0) execl("/bin/sh", "-c", argstr, (char*)0); else wait(... Note that it execs the shell, which then has to parse the string which then gets exec'd from the shell. Quite a bit different. -- Conor P. Cahill (703)430-9247 Virtual Technologies, Inc., uunet!virtech!cpcahil 46030 Manekin Plaza, Suite 160 Sterling, VA 22170