diff options
author | John Baldwin <jhb@FreeBSD.org> | 2003-03-24 21:15:35 +0000 |
---|---|---|
committer | John Baldwin <jhb@FreeBSD.org> | 2003-03-24 21:15:35 +0000 |
commit | 75b8b3b25ca74f1079044873565c0f5231e1c2a4 (patch) | |
tree | 41fad1aa97bccfd68308cf8a8ff0de8b8f243493 /sys/kern/kern_exec.c | |
parent | e34334f0a1ca1b249332eb4ffe748a4dc436ee41 (diff) | |
download | src-75b8b3b25ca74f1079044873565c0f5231e1c2a4.tar.gz src-75b8b3b25ca74f1079044873565c0f5231e1c2a4.zip |
Replace the at_fork, at_exec, and at_exit functions with the slightly more
flexible process_fork, process_exec, and process_exit eventhandlers. This
reduces code duplication and also means that I don't have to go duplicate
the eventhandler locking three more times for each of at_fork, at_exec, and
at_exit.
Reviewed by: phk, jake, almost complete silence on arch@
Notes
Notes:
svn path=/head/; revision=112564
Diffstat (limited to 'sys/kern/kern_exec.c')
-rw-r--r-- | sys/kern/kern_exec.c | 61 |
1 files changed, 2 insertions, 59 deletions
diff --git a/sys/kern/kern_exec.c b/sys/kern/kern_exec.c index a359b75d76a2..a8c668be515e 100644 --- a/sys/kern/kern_exec.c +++ b/sys/kern/kern_exec.c @@ -31,6 +31,7 @@ #include <sys/param.h> #include <sys/systm.h> +#include <sys/eventhandler.h> #include <sys/lock.h> #include <sys/mutex.h> #include <sys/sysproto.h> @@ -72,25 +73,12 @@ MALLOC_DEFINE(M_PARGS, "proc-args", "Process arguments"); -static MALLOC_DEFINE(M_ATEXEC, "atexec", "atexec callback"); - static int sysctl_kern_ps_strings(SYSCTL_HANDLER_ARGS); static int sysctl_kern_usrstack(SYSCTL_HANDLER_ARGS); static int sysctl_kern_stackprot(SYSCTL_HANDLER_ARGS); static int kern_execve(struct thread *td, char *fname, char **argv, char **envv, struct mac *mac_p); -/* - * callout list for things to do at exec time - */ -struct execlist { - execlist_fn function; - TAILQ_ENTRY(execlist) next; -}; - -TAILQ_HEAD(exec_list_head, execlist); -static struct exec_list_head exec_list = TAILQ_HEAD_INITIALIZER(exec_list); - /* XXX This should be vm_size_t. */ SYSCTL_PROC(_kern, KERN_PS_STRINGS, ps_strings, CTLTYPE_ULONG|CTLFLAG_RD, NULL, 0, sysctl_kern_ps_strings, "LU", ""); @@ -840,7 +828,6 @@ exec_new_vmspace(imgp, sv) struct sysentvec *sv; { int error; - struct execlist *ep; struct proc *p = imgp->proc; struct vmspace *vmspace = p->p_vmspace; vm_offset_t stack_addr; @@ -852,11 +839,7 @@ exec_new_vmspace(imgp, sv) imgp->vmspace_destroyed = 1; - /* - * Perform functions registered with at_exec(). - */ - TAILQ_FOREACH(ep, &exec_list, next) - (*ep->function)(p); + EVENTHANDLER_INVOKE(process_exec, p); /* * Blow away entire process VM, if address space not shared, @@ -1223,43 +1206,3 @@ exec_unregister(execsw_arg) execsw = newexecsw; return (0); } - -int -at_exec(function) - execlist_fn function; -{ - struct execlist *ep; - -#ifdef INVARIANTS - /* Be noisy if the programmer has lost track of things */ - if (rm_at_exec(function)) - printf("WARNING: exec callout entry (%p) already present\n", - function); -#endif - ep = malloc(sizeof(*ep), M_ATEXEC, M_NOWAIT); - if (ep == NULL) - return (ENOMEM); - ep->function = function; - TAILQ_INSERT_TAIL(&exec_list, ep, next); - return (0); -} - -/* - * Scan the exec callout list for the given item and remove it. - * Returns the number of items removed (0 or 1) - */ -int -rm_at_exec(function) - execlist_fn function; -{ - struct execlist *ep; - - TAILQ_FOREACH(ep, &exec_list, next) { - if (ep->function == function) { - TAILQ_REMOVE(&exec_list, ep, next); - free(ep, M_ATEXEC); - return (1); - } - } - return (0); -} |