2e20a70dbf
Should fix PR/36939 and make the rlimit code MP safe. Posted for comment to tech-kern (non received!) The p_limit field (for a process) is only be changed once (on the first write), and a reference to the old structure is kept (for code paths that have cached the pointer). Only p->p_limit is now locked by p->p_mutex, and since the referenced memory will not go away, is only needed if the pointer is to be changed. The contents of 'struct plimit' are all locked by pl_mutex, except that the code doesn't bother to acquire it for reads (which are basically atomic). Add FORK_SHARELIMIT that causes fork1() to share the limits between parent and child, use it for the IRIX_PR_SULIMIT. Fix borked test for both IRIX_PR_SUMASK and IRIX_PR_SDIR being set.