[Top] [All Lists]

Re: system() function

To: "Siders, Keith" <>
Subject: Re: system() function
From: Alan Cox <>
Date: 31 May 2002 00:02:45 +0100
Cc: "Linux-Mips (E-mail)" <>
In-reply-to: <7DF7BFDC95ECD411B4010090278A44CA379B17@ATVX>
References: <7DF7BFDC95ECD411B4010090278A44CA379B17@ATVX>
On Thu, 2002-05-30 at 17:01, Siders, Keith wrote:
> I was planning to use system() to invoke a shell and launch a script.

You can do that yes

> However it appears that this causes the parent process to terminate. A note

No it doesn't

> in Linux Programming Bible (Goerzen, 2000) says to never invoke a shell or
> use the system() function. Having looked at fork() and exec(), these will
> require obscene amounts of memory and overhead (for an embedded box). I've


> also looked at vfork() and execve(), which looks like it will do what I
> want. So do I do the vfork()/execve() pair, or is there a better way? And
> would sigaction() handling be the way to pass progress information from the
> child back to the parent process?

system is actually implemented using either vfork/execve or fork/execve
to run your command through the shell. It works great but you do need to
remember its going via the shell so things like "*" will be expanded.

fork creates a copy on write clone of the process (ie the program data
is not actually copied unless either task writes to it), so it generally
uses very little ram indeed, especially when one of them exec's

<Prev in Thread] Current Thread [Next in Thread>