[Top][All Lists]

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

Re: Resource limitation causing erractic behaviour?

From: Paul Jarc
Subject: Re: Resource limitation causing erractic behaviour?
Date: Fri, 08 Mar 2002 20:22:25 -0500
User-agent: Gnus/5.090006 (Oort Gnus v0.06) Emacs/20.7 (i386-redhat-linux-gnu)

"William L. Maltby" <address@hidden> wrote:
> Have a controlling script that near its end does
> chroot `pwd` ... /bin/bash -c "another shell" that nearits end does a
> /bin/bash --login -c "another shell" that near its end does another
> /bin/bash --login -c "another shell".
> Fix: In all but one case, change ". $WLD/source-shell" to
> "$WLD/source-shell".

I assume you're using "." to avoid the cost of fork+exec.  If you use
"exec" instead of ".", you can still avoid the fork cost, and also
avoid the accumulating memory consumption.  (With ".", each script is
held in memory while the script it sources runs.  "exec" will discard
the old script.  Of course, this is usable only if the "." command is
immediately followed by (implicit or explicit) "exit".)  In general,
you can save memory by "exec"ing the last command in a script, even if
it's not another script, instead of forking for it.

Another option, if you script A sourcing script B sourcing script C,
etc., is to use iteration instead of recursion:
set - initial-script ...
while [ "$#" != 0 ]; do
  . "$script"
Then each script can indicate that others should be sourced by
'set - "$@" other-script' or 'set - other-script "$@"', depending on
whether you want to proceed depth-first or breadth-first.


reply via email to

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