diff --git a/sys/kern/kern_exec.c b/sys/kern/kern_exec.c index 7c7a783a511b..488fc59d9aa3 100644 --- a/sys/kern/kern_exec.c +++ b/sys/kern/kern_exec.c @@ -58,7 +58,6 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include #include #ifdef KTRACE #include @@ -481,9 +480,6 @@ do_execve(td, args, mac_p) */ fdunshare(p, td); - /* Clear POSIX timers */ - itimers_event_hook(p, ITIMER_EV_EXEC); - /* * Malloc things before we need locks. */ diff --git a/sys/kern/kern_exit.c b/sys/kern/kern_exit.c index 6be9c075ccd8..024a1f7b3170 100644 --- a/sys/kern/kern_exit.c +++ b/sys/kern/kern_exit.c @@ -66,7 +66,6 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include #ifdef KTRACE #include #endif @@ -232,8 +231,6 @@ exit1(struct thread *td, int rv) sigqueue_flush(&td->td_sigqueue); PROC_UNLOCK(p); - itimers_event_hook(p, ITIMER_EV_EXIT); - /* * Reset any sigio structures pointing to us as a result of * F_SETOWN with our pid. diff --git a/sys/kern/kern_time.c b/sys/kern/kern_time.c index 4cba08fa65ef..5bbd2f0cdc0a 100644 --- a/sys/kern/kern_time.c +++ b/sys/kern/kern_time.c @@ -39,6 +39,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -86,6 +87,7 @@ static void itimer_enter(struct itimer *); static void itimer_leave(struct itimer *); static struct itimer *itimer_find(struct proc *, timer_t, int); static void itimers_alloc(struct proc *); +static void itimers_event_hook(void *arg, struct proc *p); static int realtimer_create(struct itimer *); static int realtimer_gettime(struct itimer *, struct itimerspec *); static int realtimer_settime(struct itimer *, int, @@ -889,6 +891,10 @@ itimer_start(void) p31b_setcfg(CTL_P1003_1B_TIMERS, 200112L); p31b_setcfg(CTL_P1003_1B_DELAYTIMER_MAX, INT_MAX); p31b_setcfg(CTL_P1003_1B_TIMER_MAX, TIMER_MAX); + EVENTHANDLER_REGISTER(process_exit, itimers_event_hook, + (void *)ITIMER_EV_EXIT, EVENTHANDLER_PRI_ANY); + EVENTHANDLER_REGISTER(process_exec, itimers_event_hook, + (void *)ITIMER_EV_EXEC, EVENTHANDLER_PRI_ANY); } int @@ -1504,11 +1510,12 @@ itimers_alloc(struct proc *p) } /* Clean up timers when some process events are being triggered. */ -void -itimers_event_hook(struct proc *p, int event) +static void +itimers_event_hook(void *arg, struct proc *p) { struct itimers *its; struct itimer *it; + int event = (int)arg; int i; if (p->p_itimers != NULL) {