Seleznev Anton
Seleznev Anton

Reputation: 661

System limits for child processes in linux

I am currently reading Michael Kerrisk "The Linux programming interface". In chapter dedicated to system limits it is written:

SUSv3 requires that the value returned by sysconf() for a particular limit be constant for the lifetime of the calling process.

Does that mean that if I get current system limits and use them somehow in the current process, It is a rule of good taste to get them again in a child process after fork?

Upvotes: 3

Views: 134

Answers (1)

salezica
salezica

Reputation: 76909

In principle, yes. If you want a dynamic value that reflects the actual limit set on a particular process, it's best to call sysconf() once per process.

However, some configuration values will certainly not change. For example, PAGESIZE won't be changing between calls to fork(). Invoking sysconf() again may not be necessary.

Upvotes: 2

Related Questions