Re: Sleep freezing

joe_at_invalid.address
Date: 08/11/03


Date: Mon, 11 Aug 2003 19:31:45 GMT

beagleboythefirst@hotmail.com (Tom) writes:

> Ed Morton <mortonAVOIDINGSPAM@Lucent.com> wrote in message
> news:<3F37AA37.5030609@Lucent.com>...
> > On 8/11/2003 9:04 AM, Tom wrote:
> > > Hi all,
> > >
> > > I seem to be having some problem with the sleep command and was
> > > wondering if someone could help.
> > <snip>
> > > exec /test/bin/start_server.sh > $LOGDIR/apgserver.log &
> >
> > Get rid of this "exec".
> >
> > > SERVER_PID=$!
> > > echo "Sleeping for 5 to allow Web Server to start..."
> >
> > Bet you aren't seeing this "echo" either.
> >
> > > sleep 5
> > >
> > > #echo "The current directory is : `pwd`"
> > >
> > > -----------------------------------------------------------------------
> > >
> > > I never reach the line that prints out the current directory for the
> > > second time???.
> >
> > I'd uncomment that line too 8-).
> >
> > man exec.
> >
> > Ed.
>
> Hi Ed.
>
> Thanks for your help. Sorry that second line is actually uncommented
> in my code. Just an error as I typed it in.
>
> I read the man page for exec and still dont fully understand what it
> does.
>
> Quote ->
> This command treats its arguments as the specification of
> one or more subprocesses to execute. The arguments take the
> form of a standard shell pipeline where each arg becomes one
> word of a command, and each distinct command becomes a sub-
> process.

The word "execute" means to replace the program running in the calling
process with the program specified as the first argument to
execute.

A process is an operating system defined region of (probably virtual)
memory, within which a program runs. If one program execs another, it
gets replaced by the other program in the process.

> When it says that the arguments take the form of a standard shell
> pipeline does that mean that each seperate command has to be
> seperated by a pipe symbol. Also it says that each command is
> executed in a subprocess. When you execute a command from the shell
> is it not the inherent behaviour that the command is executed as a
> subprocess?

A standard shell pipeline is defined in
http://www.opengroup.org/onlinepubs/007904975/utilities/xcu_chap02.html#tag_02_09_02

> If I have a script which calls another script in the following two
> ways what is the difference in their execution
>
> exec simplescript.sh &

I'm not sure I can answer this. Anyone know what effect & has in
an exec command line?

> and
>
> simplescript.sh &

This simply makes simplescript.sh run in the background, and the
calling shell continues executing.

> Also as a final (perhaps silly) question when a script is executed
> does this count as executing a process and will therefore have a
> processId or is it just the commands within this script that will
> have processIds?

The exec command replaces the process running the calling program with
the program being exec'd. The process id doesn't change, only what's
being run in it.

Joe