kern_fork.c (220222) | kern_fork.c (223825) |
---|---|
1/*- 2 * Copyright (c) 1982, 1986, 1989, 1991, 1993 3 * The Regents of the University of California. All rights reserved. 4 * (c) UNIX System Laboratories, Inc. 5 * All or some portions of this file are derived from material licensed 6 * to the University of California by American Telephone and Telegraph 7 * Co. or Unix System Laboratories, Inc. and are reproduced herein with 8 * the permission of UNIX System Laboratories, Inc. --- 21 unchanged lines hidden (view full) --- 30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 32 * SUCH DAMAGE. 33 * 34 * @(#)kern_fork.c 8.6 (Berkeley) 4/8/94 35 */ 36 37#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 1982, 1986, 1989, 1991, 1993 3 * The Regents of the University of California. All rights reserved. 4 * (c) UNIX System Laboratories, Inc. 5 * All or some portions of this file are derived from material licensed 6 * to the University of California by American Telephone and Telegraph 7 * Co. or Unix System Laboratories, Inc. and are reproduced herein with 8 * the permission of UNIX System Laboratories, Inc. --- 21 unchanged lines hidden (view full) --- 30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 32 * SUCH DAMAGE. 33 * 34 * @(#)kern_fork.c 8.6 (Berkeley) 4/8/94 35 */ 36 37#include <sys/cdefs.h> |
38__FBSDID("$FreeBSD: head/sys/kern/kern_fork.c 220222 2011-03-31 19:22:11Z trasz $"); | 38__FBSDID("$FreeBSD: head/sys/kern/kern_fork.c 223825 2011-07-06 20:06:44Z trasz $"); |
39 40#include "opt_kdtrace.h" 41#include "opt_ktrace.h" 42#include "opt_kstack_pages.h" 43 44#include <sys/param.h> 45#include <sys/systm.h> 46#include <sys/sysproto.h> --- 682 unchanged lines hidden (view full) --- 729 * Here we don't create a new process, but we divorce 730 * certain parts of a process from itself. 731 */ 732 if ((flags & RFPROC) == 0) { 733 *procp = NULL; 734 return (fork_norfproc(td, flags)); 735 } 736 | 39 40#include "opt_kdtrace.h" 41#include "opt_ktrace.h" 42#include "opt_kstack_pages.h" 43 44#include <sys/param.h> 45#include <sys/systm.h> 46#include <sys/sysproto.h> --- 682 unchanged lines hidden (view full) --- 729 * Here we don't create a new process, but we divorce 730 * certain parts of a process from itself. 731 */ 732 if ((flags & RFPROC) == 0) { 733 *procp = NULL; 734 return (fork_norfproc(td, flags)); 735 } 736 |
737#ifdef RACCT |
|
737 PROC_LOCK(p1); 738 error = racct_add(p1, RACCT_NPROC, 1); 739 PROC_UNLOCK(p1); 740 if (error != 0) 741 return (EAGAIN); | 738 PROC_LOCK(p1); 739 error = racct_add(p1, RACCT_NPROC, 1); 740 PROC_UNLOCK(p1); 741 if (error != 0) 742 return (EAGAIN); |
743#endif |
|
742 743 mem_charged = 0; 744 vm2 = NULL; 745 if (pages == 0) 746 pages = KSTACK_PAGES; 747 /* Allocate new proc. */ 748 newproc = uma_zalloc(proc_zone, M_WAITOK); 749 td2 = FIRST_THREAD_IN_PROC(newproc); --- 67 unchanged lines hidden (view full) --- 817 */ 818 sx_xlock(&allproc_lock); 819 if ((nprocs >= maxproc - 10 && priv_check_cred(td->td_ucred, 820 PRIV_MAXPROC, 0) != 0) || nprocs >= maxproc) { 821 error = EAGAIN; 822 goto fail; 823 } 824 | 744 745 mem_charged = 0; 746 vm2 = NULL; 747 if (pages == 0) 748 pages = KSTACK_PAGES; 749 /* Allocate new proc. */ 750 newproc = uma_zalloc(proc_zone, M_WAITOK); 751 td2 = FIRST_THREAD_IN_PROC(newproc); --- 67 unchanged lines hidden (view full) --- 819 */ 820 sx_xlock(&allproc_lock); 821 if ((nprocs >= maxproc - 10 && priv_check_cred(td->td_ucred, 822 PRIV_MAXPROC, 0) != 0) || nprocs >= maxproc) { 823 error = EAGAIN; 824 goto fail; 825 } 826 |
827#ifdef RACCT |
|
825 /* 826 * After fork, there is exactly one thread running. 827 */ 828 PROC_LOCK(newproc); 829 error = racct_set(newproc, RACCT_NTHR, 1); 830 PROC_UNLOCK(newproc); 831 if (error != 0) { 832 error = EAGAIN; 833 goto fail; 834 } | 828 /* 829 * After fork, there is exactly one thread running. 830 */ 831 PROC_LOCK(newproc); 832 error = racct_set(newproc, RACCT_NTHR, 1); 833 PROC_UNLOCK(newproc); 834 if (error != 0) { 835 error = EAGAIN; 836 goto fail; 837 } |
838#endif |
|
835 836 /* 837 * Increment the count of procs running with this uid. Don't allow 838 * a nonprivileged user to exceed their current limit. 839 * 840 * XXXRW: Can we avoid privilege here if it's not needed? 841 */ 842 error = priv_check_cred(td->td_ucred, PRIV_PROC_LIMIT, 0); --- 26 unchanged lines hidden (view full) --- 869#ifdef MAC 870 mac_proc_destroy(newproc); 871#endif 872fail1: 873 if (vm2 != NULL) 874 vmspace_free(vm2); 875 uma_zfree(proc_zone, newproc); 876 pause("fork", hz / 2); | 839 840 /* 841 * Increment the count of procs running with this uid. Don't allow 842 * a nonprivileged user to exceed their current limit. 843 * 844 * XXXRW: Can we avoid privilege here if it's not needed? 845 */ 846 error = priv_check_cred(td->td_ucred, PRIV_PROC_LIMIT, 0); --- 26 unchanged lines hidden (view full) --- 873#ifdef MAC 874 mac_proc_destroy(newproc); 875#endif 876fail1: 877 if (vm2 != NULL) 878 vmspace_free(vm2); 879 uma_zfree(proc_zone, newproc); 880 pause("fork", hz / 2); |
881#ifdef RACCT |
|
877 PROC_LOCK(p1); 878 racct_sub(p1, RACCT_NPROC, 1); 879 PROC_UNLOCK(p1); | 882 PROC_LOCK(p1); 883 racct_sub(p1, RACCT_NPROC, 1); 884 PROC_UNLOCK(p1); |
885#endif |
|
880 return (error); 881} 882 883/* 884 * Handle the return of a child process from fork1(). This function 885 * is called from the MD fork_trampoline() entry point. 886 */ 887void --- 95 unchanged lines hidden --- | 886 return (error); 887} 888 889/* 890 * Handle the return of a child process from fork1(). This function 891 * is called from the MD fork_trampoline() entry point. 892 */ 893void --- 95 unchanged lines hidden --- |