読者です 読者をやめる 読者になる 読者になる

てきとうなメモ

本の感想とか技術メモとか

[Linux] limitのデフォルト値

shellや/etc/security/limits.confで上書きされるので最初のデフォルト値ってどうやってみれば良いのかと調べてた。

initの値を見れば良いのか。

$ cat /proc/1/limits 
Limit                     Soft Limit           Hard Limit           Units     
Max cpu time              unlimited            unlimited            seconds   
Max file size             unlimited            unlimited            bytes     
Max data size             unlimited            unlimited            bytes     
Max stack size            8388608              unlimited            bytes     
Max core file size        0                    unlimited            bytes     
Max resident set          unlimited            unlimited            bytes     
Max processes             61308                61308                processes 
Max open files            1024                 4096                 files     
Max locked memory         65536                65536                bytes     
Max address space         unlimited            unlimited            bytes     
Max file locks            unlimited            unlimited            locks     
Max pending signals       61308                61308                signals   
Max msgqueue size         819200               819200               bytes     
Max nice priority         0                    0                    
Max realtime priority     0                    0                    
Max realtime timeout      unlimited            unlimited            us   

ソースコード的にはinclude/asm-generic/resource.h

/*
 * boot-time rlimit defaults for the init task:
 */
#define INIT_RLIMITS              \
{                 \
  [RLIMIT_CPU]    = {  RLIM_INFINITY,  RLIM_INFINITY }, \
  [RLIMIT_FSIZE]    = {  RLIM_INFINITY,  RLIM_INFINITY }, \
  [RLIMIT_DATA]   = {  RLIM_INFINITY,  RLIM_INFINITY }, \
  [RLIMIT_STACK]    = {       _STK_LIM,   _STK_LIM_MAX }, \
  [RLIMIT_CORE]   = {              0,  RLIM_INFINITY }, \
  [RLIMIT_RSS]    = {  RLIM_INFINITY,  RLIM_INFINITY }, \
  [RLIMIT_NPROC]    = {              0,              0 }, \
  [RLIMIT_NOFILE]   = {   INR_OPEN_CUR,   INR_OPEN_MAX }, \
  [RLIMIT_MEMLOCK]  = {    MLOCK_LIMIT,    MLOCK_LIMIT }, \
  [RLIMIT_AS]   = {  RLIM_INFINITY,  RLIM_INFINITY }, \
  [RLIMIT_LOCKS]    = {  RLIM_INFINITY,  RLIM_INFINITY }, \
  [RLIMIT_SIGPENDING] = {     0,         0 }, \
  [RLIMIT_MSGQUEUE] = {   MQ_BYTES_MAX,   MQ_BYTES_MAX }, \
  [RLIMIT_NICE]   = { 0, 0 },       \
  [RLIMIT_RTPRIO]   = { 0, 0 },       \
  [RLIMIT_RTTIME]   = {  RLIM_INFINITY,  RLIM_INFINITY }, \
}