1

Normally /etc/security/limits.h only work when you login into a shell.

How about when you fork a process in Linux, where is the value of Max open files of /proc/PID/limits is controlled by?

Howard
  • 2,135
  • 13
  • 48
  • 72

3 Answers3

3

My understanding is that such settings in the child fork get inherited from the parent. Also, you can set the limit information in your process by using the getrlimit(), setrlimit() system calls.

mdpc
  • 11,856
  • 28
  • 53
  • 67
1

The file /etc/security/limits.conf is used by pam_limits.

The command ulimit is a shell builtin command that can modify the soft and hard limits within the limits set by the PAM configuration file mentionned (unless you are root).

You can apply those limits on "login" or "ssh", etc. sessions. PAM then applies the limits on the processes (and forked processes) launched within this session. They are inherited.

Huygens
  • 1,708
  • 3
  • 20
  • 36
0

Fork will inherit the environment from the parent who forked it ... if that has a limit on fd it should be applied.

silviud
  • 2,687
  • 2
  • 18
  • 19