FreeBSD kernel kern code
kern_exit.c File Reference
#include <sys/cdefs.h>
#include "opt_ddb.h"
#include "opt_ktrace.h"
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/sysproto.h>
#include <sys/capsicum.h>
#include <sys/eventhandler.h>
#include <sys/kernel.h>
#include <sys/ktr.h>
#include <sys/malloc.h>
#include <sys/lock.h>
#include <sys/mutex.h>
#include <sys/proc.h>
#include <sys/procdesc.h>
#include <sys/jail.h>
#include <sys/tty.h>
#include <sys/wait.h>
#include <sys/vmmeter.h>
#include <sys/vnode.h>
#include <sys/racct.h>
#include <sys/resourcevar.h>
#include <sys/sbuf.h>
#include <sys/signalvar.h>
#include <sys/sched.h>
#include <sys/sx.h>
#include <sys/syscallsubr.h>
#include <sys/sysctl.h>
#include <sys/syslog.h>
#include <sys/ptrace.h>
#include <sys/acct.h>
#include <sys/filedesc.h>
#include <sys/sdt.h>
#include <sys/shm.h>
#include <sys/sem.h>
#include <sys/sysent.h>
#include <sys/timers.h>
#include <sys/umtxvar.h>
#include <security/audit/audit.h>
#include <security/mac/mac_framework.h>
#include <vm/vm.h>
#include <vm/vm_extern.h>
#include <vm/vm_param.h>
#include <vm/pmap.h>
#include <vm/vm_map.h>
#include <vm/vm_page.h>
#include <vm/uma.h>
Include dependency graph for kern_exit.c:

Go to the source code of this file.

Data Structures

struct  abort2_args
 

Functions

 __FBSDID ("$FreeBSD$")
 
 SDT_PROVIDER_DECLARE (proc)
 
 SDT_PROBE_DEFINE1 (proc,,, exit, "int")
 
 SYSCTL_INT (_kern, OID_AUTO, kill_on_debugger_exit, CTLFLAG_RWTUN, &kern_kill_on_dbg_exit, 0, "Kill ptraced processes when debugger exits")
 
 SYSCTL_BOOL (_kern, OID_AUTO, wait_dequeue_sigchld, CTLFLAG_RWTUN, &kern_wait_dequeue_sigchld, 0, "Dequeue SIGCHLD on wait(2) for live process")
 
struct proc * proc_realparent (struct proc *child)
 
void reaper_abandon_children (struct proc *p, bool exiting)
 
static void reaper_clear (struct proc *p)
 
void proc_clear_orphan (struct proc *p)
 
void exit_onexit (struct proc *p)
 
int sys_exit (struct thread *td, struct exit_args *uap)
 
void exit1 (struct thread *td, int rval, int signo)
 
int sys_abort2 (struct thread *td, struct abort2_args *uap)
 
int kern_abort2 (struct thread *td, const char *why, int nargs, void **uargs)
 
int sys_wait4 (struct thread *td, struct wait4_args *uap)
 
int sys_wait6 (struct thread *td, struct wait6_args *uap)
 
void proc_reap (struct thread *td, struct proc *p, int *status, int options)
 
static int proc_to_reap (struct thread *td, struct proc *p, idtype_t idtype, id_t id, int *status, int options, struct __wrusage *wrusage, siginfo_t *siginfo, int check_only)
 
int kern_wait (struct thread *td, pid_t pid, int *status, int options, struct rusage *rusage)
 
static void report_alive_proc (struct thread *td, struct proc *p, siginfo_t *siginfo, int *status, int options, int si_code)
 
int kern_wait6 (struct thread *td, idtype_t idtype, id_t id, int *status, int options, struct __wrusage *wrusage, siginfo_t *siginfo)
 
void proc_add_orphan (struct proc *child, struct proc *parent)
 
void proc_reparent (struct proc *child, struct proc *parent, bool set_oppid)
 

Variables

static int kern_kill_on_dbg_exit = 1
 
static bool kern_wait_dequeue_sigchld = 1
 

Function Documentation

◆ __FBSDID()

__FBSDID ( "$FreeBSD$"  )

◆ exit1()

◆ exit_onexit()

void exit_onexit ( struct proc *  p)

Definition at line 199 of file kern_exit.c.

References umtx_thread_exit().

Here is the call graph for this function:

◆ kern_abort2()

int kern_abort2 ( struct thread *  td,
const char *  why,
int  nargs,
void **  uargs 
)

Definition at line 769 of file kern_exit.c.

References exit1(), log(), sbuf_cat(), sbuf_clear(), sbuf_copyin(), sbuf_data(), sbuf_delete(), sbuf_finish(), sbuf_new(), sbuf_printf(), and sbuf_trim().

Referenced by sys_abort2().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ kern_wait()

int kern_wait ( struct thread *  td,
pid_t  pid,
int *  status,
int  options,
struct rusage *  rusage 
)

Definition at line 1199 of file kern_exit.c.

References kern_wait6().

Referenced by sys_wait4().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ kern_wait6()

int kern_wait6 ( struct thread *  td,
idtype_t  idtype,
id_t  id,
int *  status,
int  options,
struct __wrusage *  wrusage,
siginfo_t *  siginfo 
)

Definition at line 1275 of file kern_exit.c.

References proc_to_reap(), proctree_lock, and report_alive_proc().

Referenced by kern_wait(), and sys_wait6().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ proc_add_orphan()

void proc_add_orphan ( struct proc *  child,
struct proc *  parent 
)

Definition at line 1422 of file kern_exit.c.

References child, parent, and proctree_lock.

Referenced by proc_reparent(), and procdesc_close().

Here is the caller graph for this function:

◆ proc_clear_orphan()

void proc_clear_orphan ( struct proc *  p)

Definition at line 181 of file kern_exit.c.

References proctree_lock.

Referenced by exit1(), proc_reap(), proc_reparent(), and procdesc_close().

Here is the caller graph for this function:

◆ proc_realparent()

struct proc * proc_realparent ( struct proc *  child)

Definition at line 114 of file kern_exit.c.

References child, parent, and proctree_lock.

Referenced by exit1(), inferior(), jobc_parent(), kern_ptrace(), proc_reap(), reap_getpids(), and reap_status().

Here is the caller graph for this function:

◆ proc_reap()

void proc_reap ( struct thread *  td,
struct proc *  p,
int *  status,
int  options 
)

◆ proc_reparent()

void proc_reparent ( struct proc *  child,
struct proc *  parent,
bool  set_oppid 
)

Definition at line 1444 of file kern_exit.c.

References child, parent, proc_add_orphan(), proc_clear_orphan(), proctree_lock, and sigqueue_take().

Referenced by do_fork(), exit1(), kern_ptrace(), kproc_exit(), proc_reap(), procdesc_close(), and reaper_abandon_children().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ proc_to_reap()

static int proc_to_reap ( struct thread *  td,
struct proc *  p,
idtype_t  idtype,
id_t  id,
int *  status,
int  options,
struct __wrusage *  wrusage,
siginfo_t *  siginfo,
int  check_only 
)
static

Definition at line 1046 of file kern_exit.c.

References calccru(), calcru(), p_canwait(), proc_reap(), and proctree_lock.

Referenced by kern_wait6().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ reaper_abandon_children()

void reaper_abandon_children ( struct proc *  p,
bool  exiting 
)

Definition at line 135 of file kern_exit.c.

References initproc, proc_reparent(), and proctree_lock.

Referenced by proc_reap(), and reap_release().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ reaper_clear()

static void reaper_clear ( struct proc *  p)
static

Definition at line 160 of file kern_exit.c.

References proc_id_clear(), and proctree_lock.

Referenced by proc_reap().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ report_alive_proc()

static void report_alive_proc ( struct thread *  td,
struct proc *  p,
siginfo_t *  siginfo,
int *  status,
int  options,
int  si_code 
)
static

Definition at line 1240 of file kern_exit.c.

References kern_wait_dequeue_sigchld, proctree_lock, and sigqueue_take().

Referenced by kern_wait6().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SDT_PROBE_DEFINE1()

SDT_PROBE_DEFINE1 ( proc  ,
exit  ,
"int"   
)

◆ SDT_PROVIDER_DECLARE()

SDT_PROVIDER_DECLARE ( proc  )

◆ sys_abort2()

int sys_abort2 ( struct thread *  td,
struct abort2_args uap 
)

Definition at line 737 of file kern_exit.c.

References abort2_args::args, kern_abort2(), abort2_args::nargs, and abort2_args::why.

Here is the call graph for this function:

◆ sys_exit()

int sys_exit ( struct thread *  td,
struct exit_args *  uap 
)

Definition at line 209 of file kern_exit.c.

References exit1().

Here is the call graph for this function:

◆ sys_wait4()

int sys_wait4 ( struct thread *  td,
struct wait4_args *  uap 
)

Definition at line 850 of file kern_exit.c.

References kern_wait().

Here is the call graph for this function:

◆ sys_wait6()

int sys_wait6 ( struct thread *  td,
struct wait6_args *  uap 
)

Definition at line 868 of file kern_exit.c.

References kern_wait6().

Here is the call graph for this function:

◆ SYSCTL_BOOL()

SYSCTL_BOOL ( _kern  ,
OID_AUTO  ,
wait_dequeue_sigchld  ,
CTLFLAG_RWTUN  ,
kern_wait_dequeue_sigchld,
,
"Dequeue SIGCHLD on wait(2) for live process"   
)

◆ SYSCTL_INT()

SYSCTL_INT ( _kern  ,
OID_AUTO  ,
kill_on_debugger_exit  ,
CTLFLAG_RWTUN  ,
kern_kill_on_dbg_exit,
,
"Kill ptraced processes when debugger exits"   
)

Variable Documentation

◆ kern_kill_on_dbg_exit

int kern_kill_on_dbg_exit = 1
static

Definition at line 103 of file kern_exit.c.

Referenced by exit1().

◆ kern_wait_dequeue_sigchld

bool kern_wait_dequeue_sigchld = 1
static

Definition at line 108 of file kern_exit.c.

Referenced by report_alive_proc().