Setting stack and memory sizes in a script

Q&A's, tips, howto's
Post Reply
Posts: 216
Joined: Mon Jun 02, 2014 1:40 am
Location: Melbourne, Australia

Setting stack and memory sizes in a script

Post by ralph.ronnquist »

I just ran into the following quirk. Basically, I wanted to include stack and memory limits in a script and therefore thought I could do it in the script header line, as:

Code: Select all

!#/usr/bin/newlisp -s 4096 -m 100
but then I discovered that only the first of these options come into play.

Eventually I learnt that the "optional arguments" for the script interpreter are actually passed in as a single first command line argument of the whole rest of line (this is on Linux), and newlisp happily and silently(!) takes an argument of '-s 4096 -m 100' to be the same as '-s4096'. Also, it appears that the handling and delivery of optional arguments may vary across platforms, so maybe one shouldn't use them at all.

But then, how do I make the script set its limits (and other options)? Do I have to have a separate wrapper shell script for its invocation?

Posts: 5285
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California

Re: Setting stack and memory sizes in a script

Post by Lutz »

The only way to make options works consistently on different OSs is when options are specified on the command line - or in a wrapper shell script - and not in the script "#!" line.

Currently your example would only work correcty on Mac OS X, all others will only take the first option. I will try to make it work for other OSs in a future version.

Post Reply