1
0
mirror of https://git.FreeBSD.org/src.git synced 2025-01-26 16:18:31 +00:00

Compare p_cpulimit with RLIM_INFINITY before comparing it with the process

runtime. p_runtime is unsigned while p_cpulimit is not, so this avoids the
nasty side effect of the process getting killed when the runtime comes up
"negative" due to other bugs.
This commit is contained in:
David Greenman 1998-11-27 11:44:22 +00:00
parent fcd70874b4
commit f2b678d4cb
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=41373

View File

@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)kern_synch.c 8.9 (Berkeley) 5/19/95
* $Id: kern_synch.c,v 1.67 1998/11/26 14:05:58 bde Exp $
* $Id: kern_synch.c,v 1.68 1998/11/26 16:49:55 bde Exp $
*/
#include "opt_ktrace.h"
@ -650,7 +650,8 @@ mi_switch()
* Check if the process exceeds its cpu resource allocation.
* If over max, kill it.
*/
if (p->p_stat != SZOMB && p->p_runtime > p->p_limit->p_cpulimit) {
if (p->p_stat != SZOMB && p->p_limit->p_cpulimit != RLIM_INFINITY &&
p->p_runtime > p->p_limit->p_cpulimit) {
rlim = &p->p_rlimit[RLIMIT_CPU];
if (p->p_runtime / (rlim_t)1000000 >= rlim->rlim_max) {
killproc(p, "exceeded maximum CPU limit");