Are ulimits inherited by the shell, by the user, or a combination?

When a process spawns a subshell, how is the ulimit inherited?

Is it by user, by shell, or a combination?

Specifically, this was found in the context of HP Server Automation jobs failing on some managed AIX devices because of an interaction between the soft and hard ulimits in place. In short, the Agent (which runs as root and generates a subshell when processing commands from SA) was unable to process some jobs because its subshell was hitting a ulimit.

Increasing the ulimit solved the problem, but the question of how the ulimit is inherited, and whether the soft or hard (or both) limits need to be raised is left open.

What is the appropriate answer to this question? It may be AIX-specific, or it may be across Unix/Linux variants - whichever is better.


Solution 1:

The details of implementation vary across *nix platforms , but ulimit is initially set per user, with a default for all users that covers those who lack a specific setting.

In the specific case of AIX, these settings are in /etc/security/limits. Linux uses the slightly-different name /etc/security/limits.conf to do the same job. To be safe, do man ulimit to find the answer for your particular OS.