FreeBSD kernel kern code
kern_fork.c File Reference
#include <sys/cdefs.h>
#include "opt_kdtrace.h"
#include "opt_ktrace.h"
#include "opt_kstack_pages.h"
#include "opt_procdesc.h"
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/sysproto.h>
#include <sys/eventhandler.h>
#include <sys/fcntl.h>
#include <sys/filedesc.h>
#include <sys/jail.h>
#include <sys/kernel.h>
#include <sys/kthread.h>
#include <sys/sysctl.h>
#include <sys/lock.h>
#include <sys/malloc.h>
#include <sys/mutex.h>
#include <sys/priv.h>
#include <sys/proc.h>
#include <sys/procdesc.h>
#include <sys/pioctl.h>
#include <sys/ptrace.h>
#include <sys/racct.h>
#include <sys/resourcevar.h>
#include <sys/sched.h>
#include <sys/syscall.h>
#include <sys/vmmeter.h>
#include <sys/vnode.h>
#include <sys/acct.h>
#include <sys/ktr.h>
#include <sys/ktrace.h>
#include <sys/unistd.h>
#include <sys/sdt.h>
#include <sys/sx.h>
#include <sys/sysent.h>
#include <sys/signalvar.h>
#include <security/audit/audit.h>
#include <security/mac/mac_framework.h>
#include <vm/vm.h>
#include <vm/pmap.h>
#include <vm/vm_map.h>
#include <vm/vm_extern.h>
#include <vm/uma.h>
Include dependency graph for kern_fork.c:

Go to the source code of this file.

Data Structures

struct  fork_args
 

Functions

 __FBSDID ("$BSDSUniX$")
 
 SDT_PROVIDER_DECLARE (proc)
 
 SDT_PROBE_DEFINE3 (proc, kernel,, create,"struct proc *","struct proc *","int")
 
int sys_fork (struct thread *td, struct fork_args *uap)
 
int sys_pdfork (struct thread *td, struct pdfork_args *uap)
 
int sys_vfork (struct thread *td, struct vfork_args *uap)
 
int sys_rfork (struct thread *td, struct rfork_args *uap)
 
 SYSCTL_INT (_kern, OID_AUTO, lastpid, CTLFLAG_RD,&lastpid, 0,"Last used PID")
 
static int sysctl_kern_randompid (SYSCTL_HANDLER_ARGS)
 
 SYSCTL_PROC (_kern, OID_AUTO, randompid, CTLTYPE_INT|CTLFLAG_RW, 0, 0, sysctl_kern_randompid,"I","Random PID modulus")
 
static int fork_findpid (int flags)
 
static int fork_norfproc (struct thread *td, int flags)
 
static void do_fork (struct thread *td, int flags, struct proc *p2, struct thread *td2, struct vmspace *vm2, int pdflags)
 
int fork1 (struct thread *td, int flags, int pages, struct proc **procp, int *procdescp, int pdflags)
 
void fork_exit (void(*callout)(void *, struct trapframe *), void *arg, struct trapframe *frame)
 
void fork_return (struct thread *td, struct trapframe *frame)
 

Variables

int nprocs = 1
 
int lastpid = 0
 
static int randompid = 0
 

Function Documentation

__FBSDID ( "$BSDSUniX$"  )
static void do_fork ( struct thread *  td,
int  flags,
struct proc *  p2,
struct thread *  td2,
struct vmspace *  vm2,
int  pdflags 
)
static
int fork1 ( struct thread *  td,
int  flags,
int  pages,
struct proc **  procp,
int *  procdescp,
int  pdflags 
)
void fork_exit ( void(*)(void *, struct trapframe *)  callout,
void *  arg,
struct trapframe *  frame 
)

Definition at line 968 of file kern_fork.c.

References Giant, kthread_exit(), printf(), sched_fork_exit(), and thread_stash().

Here is the call graph for this function:

static int fork_findpid ( int  flags)
static

Definition at line 227 of file kern_fork.c.

References allproc, allproc_lock, lastpid, pid_max, proctree_lock, randompid, and zombproc.

Referenced by do_fork().

Here is the caller graph for this function:

static int fork_norfproc ( struct thread *  td,
int  flags 
)
static

Definition at line 319 of file kern_fork.c.

References fdfree(), fdinit(), fdunshare(), thread_single(), and thread_single_end().

Referenced by fork1().

Here is the call graph for this function:

Here is the caller graph for this function:

void fork_return ( struct thread *  td,
struct trapframe *  frame 
)

Definition at line 1024 of file kern_fork.c.

References Giant, proc_reparent(), proctree_lock, ptracestop(), and userret().

Here is the call graph for this function:

SDT_PROBE_DEFINE3 ( proc  ,
kernel  ,
create  ,
"struct proc *"  ,
"struct proc *"  ,
"int"   
)
SDT_PROVIDER_DECLARE ( proc  )
int sys_fork ( struct thread *  td,
struct fork_args uap 
)

Definition at line 104 of file kern_fork.c.

References fork1().

Here is the call graph for this function:

int sys_pdfork ( struct thread *  td,
struct pdfork_args *  uap 
)

Definition at line 119 of file kern_fork.c.

References fd, and fork1().

Here is the call graph for this function:

int sys_rfork ( struct thread *  td,
struct rfork_args *  uap 
)

Definition at line 166 of file kern_fork.c.

References fork1().

Here is the call graph for this function:

int sys_vfork ( struct thread *  td,
struct vfork_args *  uap 
)

Definition at line 147 of file kern_fork.c.

References fork1().

Here is the call graph for this function:

SYSCTL_INT ( _kern  ,
OID_AUTO  ,
lastpid  ,
CTLFLAG_RD  ,
lastpid,
,
"Last used PID"   
)
static int sysctl_kern_randompid ( SYSCTL_HANDLER_ARGS  )
static

Definition at line 200 of file kern_fork.c.

References allproc_lock, pid_max, randompid, sysctl_handle_int(), and sysctl_wire_old_buffer().

Here is the call graph for this function:

SYSCTL_PROC ( _kern  ,
OID_AUTO  ,
randompid  ,
CTLTYPE_INT|  CTLFLAG_RW,
,
,
sysctl_kern_randompid  ,
"I"  ,
"Random PID modulus"   
)

Variable Documentation

int lastpid = 0

Definition at line 185 of file kern_fork.c.

Referenced by fork_findpid().

int nprocs = 1

Definition at line 184 of file kern_fork.c.

Referenced by do_fork(), fork1(), and proc_reap().

int randompid = 0
static

Definition at line 197 of file kern_fork.c.

Referenced by fork_findpid(), and sysctl_kern_randompid().