public int setrlimit(int resource, long rlimCur, long rlimMax) { RLimit rlim = new DefaultNativeRLimit(getRuntime()); rlim.init(rlimCur, rlimMax); return libc().setrlimit(resource, rlim); }
/** * I'm not actually sure if mirror needs this check, because Watchman insinuates * it's likely to be low on Mac OS, but I don't use Mac OS, so I can't really say * how often/if this would happen. * * But it's easy enough to check for anyway, and really most developer machines * should have an increased ulimit anyway. */ private static boolean checkFileDescriptorLimit() { RLimit limit = posix.getrlimit(RLIMIT_NOFILE.intValue()); if (limit.rlimCur() < limit.rlimMax()) { log.info("Increasing file limit to {}", limit.rlimMax()); posix.setrlimit(RLIMIT_NOFILE.intValue(), limit.rlimMax(), limit.rlimMax()); limit = posix.getrlimit(RLIMIT_NOFILE.intValue()); } if (limit.rlimCur() < 10240) { log.error("Your file limit is {} and should probably be increased", limit); log.info(" See https://facebook.github.io/watchman/docs/install.html#system-specific-preparation"); log.info(" E.g. run: sudo sysctl -w kern.maxfiles=10485760 && sudo sysctl -w kern.maxfilesperproc=1048576"); log.info(" Or use --skip-limit-checks to ignore this"); return false; } return true; }
public int setrlimit(int resource, long rlimCur, long rlimMax) { RLimit rlim = new DefaultNativeRLimit(getRuntime()); rlim.init(rlimCur, rlimMax); return libc().setrlimit(resource, rlim); }
public static IRubyObject getrlimit(Ruby runtime, IRubyObject arg) { if (!runtime.getPosix().isNative() || Platform.IS_WINDOWS) { runtime.getWarnings().warn("Process#getrlimit not supported on this platform"); return runtime.newFixnum(Long.MAX_VALUE); } RLimit rlimit = runtime.getPosix().getrlimit(rlimitResourceType(runtime, arg)); return runtime.newArray(runtime.newFixnum(rlimit.rlimCur()), runtime.newFixnum(rlimit.rlimMax())); }
public int setrlimit(int resource, long rlimCur, long rlimMax) { RLimit rlim = new DefaultNativeRLimit(getRuntime()); rlim.init(rlimCur, rlimMax); return libc().setrlimit(resource, rlim); }
public static IRubyObject getrlimit(Ruby runtime, IRubyObject arg) { if (!runtime.getPosix().isNative() || Platform.IS_WINDOWS) { runtime.getWarnings().warn("Process#getrlimit not supported on this platform"); return runtime.newFixnum(Long.MAX_VALUE); } RLimit rlimit = runtime.getPosix().getrlimit(rlimitResourceType(runtime, arg)); return runtime.newArray(runtime.newFixnum(rlimit.rlimCur()), runtime.newFixnum(rlimit.rlimMax())); }
@JRubyMethod(name = "setrlimit", module = true, visibility = PRIVATE) public static IRubyObject setrlimit(ThreadContext context, IRubyObject recv, IRubyObject resource, IRubyObject rlimCur, IRubyObject rlimMax) { Ruby runtime = context.runtime; RLimit rlim = runtime.getPosix().getrlimit(0); if (rlimMax == context.nil) rlimMax = rlimCur; rlim.init(rlimitResourceValue(runtime, rlimCur), rlimitResourceValue(runtime, rlimMax)); if (runtime.getPosix().setrlimit(rlimitResourceType(runtime, resource), rlim) < 0) { throw runtime.newErrnoFromInt(runtime.getPosix().errno(), "setrlimit"); } return context.nil; }
@JRubyMethod(name = "setrlimit", module = true, visibility = PRIVATE) public static IRubyObject setrlimit(ThreadContext context, IRubyObject recv, IRubyObject resource, IRubyObject rlimCur, IRubyObject rlimMax) { Ruby runtime = context.runtime; RLimit rlim = runtime.getPosix().getrlimit(0); if (rlimMax == context.nil) rlimMax = rlimCur; rlim.init(rlimitResourceValue(runtime, rlimCur), rlimitResourceValue(runtime, rlimMax)); if (runtime.getPosix().setrlimit(rlimitResourceType(runtime, resource), rlim) < 0) { throw runtime.newErrnoFromInt(runtime.getPosix().errno(), "setrlimit"); } return context.nil; }