File Descriptors per Process

A file descriptor is a handle created by a process when a file is opened. There is a limit to the amount of file descriptors per process. In order to check the default limit of the system, you can use command:

  1. ulimit -a # all limitations
  2. ulimit -Sn # soft limit
  3. ulimit -Hn # hard limit

If the file descriptor limit is exceeded for a process, you may see the error Too Many Open Files.

And if you want to change the limit per process temporarily, you can:

  1. ulimit -n <desired_#> # both
  2. ulimit -Sn <desired_#> # soft limit
  3. ulimit -Hn <desired_#> # hard limit

To check the open files of a process, you can use command pfiles <PID>.

To check the run time limit of each process in Solaris, you can plimit <PID>(it seems this command is not supported in Linux). If you have the root permission and you want to change the limit of an process without killing or restarting the process, you can plimit -n <desired_#>.

It was said that it may be dangerous to set the soft limit higher than 256 or hard limit greater than 1024 due to limitations with the stdio library.If programs require more file descriptors, they should use setrlimit directly.

-------------
References:

  1. File descriptors
  2. Linux Increase The Maximum Number Of Open Files / File Descriptors (FD)
  3. Linux / UNIX: List Open Files for Process
  4. Princeton University Enterprise Servers and Storage, File Descriptors
  5. plimit
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值