Skip to content

Ulimit

ULIMIT(3)

ulimit(1)

ulimit -c unlimited

如果你是一个linux OS的开发者,建议你在你的.bash_profile中添加上上述语句,它告诉OS,不限制core dump file的大小,这样当你的process执行了错误的操作而被OS终止的时候,一来,你可以及时的获知这种情况的发送,而来,你可以通过gdb来进行分析。

ulimit: core file size: cannot modify limit: Operation not permitted

有的时候,执行ulimit -c unlimited会报这种错误,修改方案参见这个链接

ulimit is a shell builtin, and thus only affects the current shell, and processes started by that shell:

$ type ulimit
ulimit is a shell builtin

From man ulimit:

The  ulimit  utility  shall  set  or report the file-size writing limit
imposed on files written by the shell and its child processes (files of
any  size  may be read). Only a process with appropriate privileges can
increase the limit.

So, yes, child processes are affected.

To set limits permanently or for all processes, edit /etc/security/limits.conf and reboot. The examples in the manpage are fairly good. You just need to add something like:

username - core unlimited