【问题标题】:ulimit first call ok second call fail, why?ulimit 第一次调用ok 第二次调用失败,为什么?
【发布时间】:2011-07-11 21:23:19
【问题描述】:

在 macOS 10.7 上,使用 bash

第一次调用 ulimit -n 成功,第二次失败。

a:$ ulimit -n 
2560
a:$ ulimit -n 5000
a:$ ulimit -n 
5000
a:$ ulimit -n 6000
bash: ulimit: open files: cannot modify limit: Operation not permitted

但是,如果我在新的 shell(或另一个 shell)中尝试 ulimit -n 6000,它会成功:

a:$ ulimit -n 
2560
a:$ ulimit -n 6000
a:$ ulimit -n 
6000

这是为什么呢?

【问题讨论】:

标签: macos unix ulimit osx-snow-leopard


【解决方案1】:

来自 bash 手册页:

硬限制一旦设置就不能增加;软限制可能是 增加到硬限制的值。如果 -H 和 -S 都不是 指定时,软限制和硬限制都已设置。

大多数现代*NIX 实际上不再使用ulimit。我猜OS X没有设置ulimit hard max,所以你的第一个调用设置了soft max和hard max,所以你的第二个调用每次都失败。没有 [limit] 参数的第一个调用可能是打印软最大值。

【讨论】:

    猜你喜欢
    • 2019-09-07
    • 2012-07-31
    • 1970-01-01
    • 2018-10-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多