-
Notifications
You must be signed in to change notification settings - Fork 110
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
37 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/bin/sh | ||
|
||
if [ $# -lt 2 ]; then | ||
echo "Usage: $(basename $0) <STACK_SIZE> <COMMAND>" >&2 | ||
echo "Run COMMAND in a shell with a maximum stack size of" >&2 | ||
echo "at least STACK_SIZE in kilobytes." >&2 | ||
exit 1 | ||
fi | ||
min_stack=$1; shift | ||
|
||
# Note: A max stack size of "unlimited" may not actually | ||
# be unlimited. For example, on Linux, using "unlimited" | ||
# results in a max stack size of 2 MB, which | ||
# is less than the default max stack size of 8 MB. | ||
# How confusing! | ||
|
||
stack=$(ulimit -s) | ||
if [ "$stack" = "unlimited" ] || [ "$stack" -lt "$min_stack" ]; then | ||
ulimit -s $min_stack | ||
fi | ||
stack=$(ulimit -s) | ||
|
||
echo "Running with max stack size of $stack KB: $*" >&2 | ||
exec /bin/sh -c "$*" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters