-/* $OpenBSD: kern_resource.c,v 1.89 2024/10/01 09:22:25 claudio Exp $ */
+/* $OpenBSD: kern_resource.c,v 1.90 2024/10/03 10:20:05 claudio Exp $ */
/* $NetBSD: kern_resource.c,v 1.38 1996/10/23 07:19:38 matthias Exp $ */
/*-
rucheck(void *arg)
{
struct rlimit rlim;
+ struct tusage tu = { 0 };
struct process *pr = arg;
+ struct proc *q;
time_t runtime;
KERNEL_ASSERT_LOCKED();
- SCHED_LOCK();
- runtime = pr->ps_tu.tu_runtime.tv_sec;
- SCHED_UNLOCK();
-
mtx_enter(&pr->ps_mtx);
rlim = pr->ps_limit->pl_rlimit[RLIMIT_CPU];
+ tuagg_sumup(&tu, &pr->ps_tu);
+ TAILQ_FOREACH(q, &pr->ps_threads, p_thr_link)
+ tuagg_sumup(&tu, &q->p_tu);
mtx_leave(&pr->ps_mtx);
+ runtime = tu.tu_runtime.tv_sec;
+
if ((rlim_t)runtime >= rlim.rlim_cur) {
if ((rlim_t)runtime >= rlim.rlim_max) {
prsignal(pr, SIGKILL);