help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-bash] Different methods of running scripts; subshells and exec


From: Greg Wooledge
Subject: Re: [Help-bash] Different methods of running scripts; subshells and execute privileges
Date: Wed, 19 Aug 2015 10:38:11 -0400
User-agent: Mutt/1.4.2.3i

On Wed, Aug 19, 2015 at 07:28:53AM -0700, Michael Convey wrote:
> ???Thank you both for your explanations. I'm trying to understand the
> difference between the script execution method using the 'exec'???
> 
> ???command and using one of the standard methods, but the following
> explanation is unclear to me:
> 
> ???
> "exec is not truly a script execution method. It does not create a subshell
> but instead replaces the current shell with an *executable image
> environment* to run the script."

The "exec" command is the shell's way of calling execve() or related
system calls.  If you're familiar with the fork/exec model of Unix
processes, this is the exec half of that.

In simple terms, exec replaces one running process with a different
program.  The new program takes over where the original one left off.
It keeps the same process ID, the same enviroment, and the same open
files.

Where this is normally used in bash is when writing a "wrapper script".
See http://mywiki.wooledge.org/WrapperScript for some examples.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]