Merge pull request #7915 from poettering/pids-max-tweak

This commit is contained in:
Zbigniew Jędrzejewski-Szmek
2018-01-25 10:24:35 +01:00
12 changed files with 313 additions and 49 deletions
+19
View File
@@ -184,3 +184,22 @@ static inline int safe_fork(const char *name, ForkFlags flags, pid_t *ret_pid) {
}
int fork_agent(const char *name, const int except[], unsigned n_except, pid_t *pid, const char *path, ...);
#if SIZEOF_PID_T == 4
/* The highest possibly (theoretic) pid_t value on this architecture. */
#define PID_T_MAX ((pid_t) INT32_MAX)
/* The maximum number of concurrent processes Linux allows on this architecture, as well as the highest valid PID value
* the kernel will potentially assign. This reflects a value compiled into the kernel (PID_MAX_LIMIT), and sets the
* upper boundary on what may be written to the /proc/sys/kernel/pid_max sysctl (but do note that the sysctl is off by
* 1, since PID 0 can never exist and there can hence only be one process less than the limit would suggest). Since
* these values are documented in proc(5) we feel quite confident that they are stable enough for the near future at
* least to define them here too. */
#define TASKS_MAX 4194303U
#elif SIZEOF_PID_T == 2
#define PID_T_MAX ((pid_t) INT16_MAX)
#define TASKS_MAX 32767U
#else
#error "Unknown pid_t size"
#endif
assert_cc(TASKS_MAX <= (unsigned long) PID_T_MAX)