aboutsummaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorKonstantin Belousov <kib@FreeBSD.org>2020-11-23 17:29:25 +0000
committerKonstantin Belousov <kib@FreeBSD.org>2020-11-23 17:29:25 +0000
commit87a9b18d2286d185d574e7f3ffc23c446d343ca4 (patch)
tree267303c56facc44c53ac4781f36ec353c8e63384 /sys
parentcaeb270e9fa89b24d61775541b15c61a23c0e829 (diff)
downloadsrc-87a9b18d2286d185d574e7f3ffc23c446d343ca4.tar.gz
src-87a9b18d2286d185d574e7f3ffc23c446d343ca4.zip
Notes
Diffstat (limited to 'sys')
-rw-r--r--sys/kern/kern_exec.c2
-rw-r--r--sys/kern/kern_exit.c7
-rw-r--r--sys/kern/kern_kthread.c5
-rw-r--r--sys/kern/kern_thr.c3
-rw-r--r--sys/sys/sysent.h3
5 files changed, 20 insertions, 0 deletions
diff --git a/sys/kern/kern_exec.c b/sys/kern/kern_exec.c
index 6a61ce17a989..b3fcbef0289b 100644
--- a/sys/kern/kern_exec.c
+++ b/sys/kern/kern_exec.c
@@ -1051,6 +1051,8 @@ exec_new_vmspace(struct image_params *imgp, struct sysentvec *sv)
sigfastblock_clear(td);
umtx_exec(p);
itimers_exec(p);
+ if (sv->sv_onexec != NULL)
+ sv->sv_onexec(p, imgp);
EVENTHANDLER_DIRECT_INVOKE(process_exec, p, imgp);
diff --git a/sys/kern/kern_exit.c b/sys/kern/kern_exit.c
index 9d70d95a5522..0e748751d019 100644
--- a/sys/kern/kern_exit.c
+++ b/sys/kern/kern_exit.c
@@ -72,6 +72,7 @@ __FBSDID("$FreeBSD$");
#include <sys/sdt.h>
#include <sys/shm.h>
#include <sys/sem.h>
+#include <sys/sysent.h>
#include <sys/timers.h>
#include <sys/umtx.h>
#ifdef KTRACE
@@ -327,6 +328,9 @@ exit1(struct thread *td, int rval, int signo)
itimers_exit(p);
+ if (p->p_sysent->sv_onexit != NULL)
+ p->p_sysent->sv_onexit(p);
+
/*
* Check if any loadable modules need anything done at process exit.
* E.g. SYSV IPC stuff.
@@ -561,6 +565,9 @@ exit1(struct thread *td, int rval, int signo)
PROC_LOCK(p);
p->p_xthread = td;
+ if (p->p_sysent->sv_ontdexit != NULL)
+ p->p_sysent->sv_ontdexit(td);
+
#ifdef KDTRACE_HOOKS
/*
* Tell the DTrace fasttrap provider about the exit if it
diff --git a/sys/kern/kern_kthread.c b/sys/kern/kern_kthread.c
index 5cc4bd275bcd..d049a099847c 100644
--- a/sys/kern/kern_kthread.c
+++ b/sys/kern/kern_kthread.c
@@ -39,6 +39,7 @@ __FBSDID("$FreeBSD$");
#include <sys/resourcevar.h>
#include <sys/rwlock.h>
#include <sys/signalvar.h>
+#include <sys/sysent.h>
#include <sys/sx.h>
#include <sys/umtx.h>
#include <sys/unistd.h>
@@ -355,6 +356,10 @@ kthread_exit(void)
PROC_UNLOCK(p);
kproc_exit(0);
}
+
+ if (p->p_sysent->sv_ontdexit != NULL)
+ p->p_sysent->sv_ontdexit(td);
+
tidhash_remove(td);
umtx_thread_exit(td);
tdsigcleanup(td);
diff --git a/sys/kern/kern_thr.c b/sys/kern/kern_thr.c
index f3e4e3649855..69259d78811a 100644
--- a/sys/kern/kern_thr.c
+++ b/sys/kern/kern_thr.c
@@ -353,6 +353,9 @@ kern_thr_exit(struct thread *td)
return (0);
}
+ if (p->p_sysent->sv_ontdexit != NULL)
+ p->p_sysent->sv_ontdexit(td);
+
td->td_dbgflags |= TDB_EXIT;
if (p->p_ptevents & PTRACE_LWP) {
p->p_pendingexits++;
diff --git a/sys/sys/sysent.h b/sys/sys/sysent.h
index 3b0df46e42a6..db729239243f 100644
--- a/sys/sys/sysent.h
+++ b/sys/sys/sysent.h
@@ -145,6 +145,9 @@ struct sysentvec {
u_long *sv_hwcap2; /* Value passed in AT_HWCAP2. */
const char *(*sv_machine_arch)(struct proc *);
vm_offset_t sv_fxrng_gen_base;
+ void (*sv_onexec)(struct proc *, struct image_params *);
+ void (*sv_onexit)(struct proc *);
+ void (*sv_ontdexit)(struct thread *td);
};
#define SV_ILP32 0x000100 /* 32-bit executable. */