bug-bash
[Top][All Lists]
Advanced

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

Re: Recursively calling a bash script goes undetected and eats all syste


From: Marc Herbert
Subject: Re: Recursively calling a bash script goes undetected and eats all system memory
Date: Fri, 10 Dec 2010 10:19:20 +0000
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.12) Gecko/20101103 Fedora/1.0-0.33.b2pre.fc14 Thunderbird/3.1.6

> Would it not be simple to add some kind of protection against this

As already mentioned, recursion is a perfectly valid programming
technique so you really cannot forbid it (in fact it is equivalent to
iteration <http://en.wikipedia.org/wiki/Recursion_(computer_science)>

Would you also forbid a shell function to call itself?


What you really want is proving termination. Unfortunately this is a
research topic <http://en.wikipedia.org/wiki/Termination_analysis>

Insanely dynamic languages like Unix shell scripting are the most
ill-suited for trying to prove anything.


> say don't let a script call itself more than 100 times?

Yes, in many environment you can configure a maximum recursion level
after which the program gone wild is killed. In your case "ulimit"
might help.





reply via email to

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