How to increase the max user processes hard limit(Mojave)
Solution 1:
Looks like kernel is hard coded to 2500 in param.c
#if CONFIG_EMBEDDED
#define NPROC 1000 /* Account for TOTAL_CORPSES_ALLOWED by making this slightly lower than we can. */
#define NPROC_PER_UID 950
#else
#define NPROC (20 + 16 * 32)
#define NPROC_PER_UID (NPROC/2)
#endif
/* NOTE: maxproc and hard_maxproc values are subject to device specific scaling in bsd_scale_setup */
#define HNPROC 2500 /* based on thread_max */
int maxproc = NPROC;
int maxprocperuid = NPROC_PER_UID;
#if CONFIG_EMBEDDED
int hard_maxproc = NPROC; /* hardcoded limit -- for embedded the number of processes is limited by the ASID space */
#else
int hard_maxproc = HNPROC; /* hardcoded limit */
#endif
and while this may be scaled in bcd_scale_setup (if you are running server version), hard_maxproc is always taken as upper limit according to syslimits.h
#if !defined(_ANSI_SOURCE)
/*
* Note: CHILD_MAX *must* be less than hard_maxproc, which is set at
* compile time; you *cannot* set it higher than the hard limit!!
*/
#define ARG_MAX (256 * 1024) /* max bytes for an exec function */
#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)
#define CHILD_MAX 266 /* max simultaneous processes */