diff --git a/AppKit/Jakefile b/AppKit/Jakefile index b465b9f15..70db16a3d 100644 --- a/AppKit/Jakefile +++ b/AppKit/Jakefile @@ -1,8 +1,10 @@ require("../common.jake"); -var framework = require("objective-j/jake").framework; -var BundleTask = require("objective-j/jake").BundleTask; +checkUlimit(); + +var framework = require("objective-j/jake").framework, + BundleTask = require("objective-j/jake").BundleTask; $BUILD_PATH = FILE.join($BUILD_DIR, $CONFIGURATION, 'AppKit'); diff --git a/Tools/nib2cib/main.j b/Tools/nib2cib/main.j index 3e5475c9d..e00eae9ae 100644 --- a/Tools/nib2cib/main.j +++ b/Tools/nib2cib/main.j @@ -22,9 +22,33 @@ @import "Nib2Cib.j" +var OS = require("OS"), + stream = require("narwhal/term").stream; + + function main(args) { + checkUlimit(); + var nib2cib = [[Nib2Cib alloc] initWithArgs:args]; [nib2cib run]; } + +function checkUlimit() +{ + var minUlimit = 1024, + p = OS.popen(["ulimit", "-n"]); + + if (p.wait() === 0) + { + var limit = p.stdout.read().split("\n")[0]; + + if (Number(limit) < minUlimit) + { + stream.print("\0red(\0bold(WARNING:\0)\0) nib2cib may need to open more files than this terminal session currently allows (" + limit + "). Add the following line to your login configuration file (.bash_profile, .bashrc, etc.), start a new terminal session, then try again:\n"); + stream.print("ulimit -n " + minUlimit); + OS.exit(1); + } + } +} diff --git a/common.jake b/common.jake index 9eded1280..eb2b2dbdc 100644 --- a/common.jake +++ b/common.jake @@ -540,6 +540,25 @@ global.colorPrint = function(/* String */ message, /* String */ color) stream.print(colorize(message, color)); }; +var minUlimit = 1024; + +global.checkUlimit = function() +{ + var p = OS.popen(["ulimit", "-n"]); + + if (p.wait() === 0) + { + var limit = p.stdout.read().split("\n")[0]; + + if (Number(limit) < minUlimit) + { + stream.print("\0red(\0bold(WARNING:\0)\0) Cappuccino may need to open more files than this terminal session currently allows (" + limit + "). Add the following line to your login configuration file (.bash_profile, .bashrc, etc.), start a new terminal session, then try again:\n"); + stream.print("ulimit -n " + minUlimit); + OS.exit(1); + } + } +} + // built in tasks diff --git a/narwhal.local.conf b/narwhal.local.conf index 235176eab..9fe4e691b 100644 --- a/narwhal.local.conf +++ b/narwhal.local.conf @@ -1,9 +1,3 @@ if [ -z "$NARWHAL_ENGINE" ] && [ -d "$NARWHAL_HOME/packages/narwhal-jsc" ]; then export NARWHAL_ENGINE=jsc fi - -if [ "$NARWHAL_ENGINE" == jsc ] && [ `ulimit -n` -lt 512 ]; then - # JSC and Narwhal together have some trouble closing files, leading to the Cappuccino - # build process crashing with a "popen error (pipe): Too many open files" error. - ulimit -n 512 -fi