@@ -144,7 +144,7 @@ bool is_cgroup_v2 = false;
144
144
145
145
double walltimelimit[2 ], cputimelimit[2 ]; /* in seconds, soft and hard limits */
146
146
int walllimit_reached, cpulimit_reached; /* 1=soft, 2=hard, 3=both limits reached */
147
- int64_t memsize;
147
+ rlim_t memsize;
148
148
rlim_t filesize;
149
149
rlim_t nproc;
150
150
size_t streamsize;
@@ -550,15 +550,15 @@ void cgroup_create()
550
550
if (is_cgroup_v2) {
551
551
// TODO: do we want to set cpu.weight here as well?
552
552
if (memsize != RLIM_INFINITY) {
553
- cgroup_add_value (int64 , " memory.max" , memsize);
554
- cgroup_add_value (int64 , " memory.swap.max" , 0 );
553
+ cgroup_add_value (uint64 , " memory.max" , memsize);
554
+ cgroup_add_value (uint64 , " memory.swap.max" , 0 );
555
555
} else {
556
556
cgroup_add_value (string, " memory.max" , " max" );
557
557
cgroup_add_value (string, " memory.swap.max" , " max" );
558
558
}
559
559
} else {
560
- cgroup_add_value (int64 , " memory.limit_in_bytes" , memsize);
561
- cgroup_add_value (int64 , " memory.memsw.limit_in_bytes" , memsize);
560
+ cgroup_add_value (uint64 , " memory.limit_in_bytes" , memsize);
561
+ cgroup_add_value (uint64 , " memory.memsw.limit_in_bytes" , memsize);
562
562
}
563
563
564
564
/* Set up cpu restrictions; we pin the task to a specific set of
@@ -613,11 +613,12 @@ void cgroup_attach()
613
613
void cgroup_kill ()
614
614
{
615
615
/* kill any remaining tasks, and wait for them to be gone */
616
+ char mem_controller[10 ] = " memory" ;
616
617
if (is_cgroup_v2) {
617
618
int size;
618
619
do {
619
620
pid_t * pids;
620
- int ret = cgroup_get_procs (cgroupname, " memory " , &pids, &size);
621
+ int ret = cgroup_get_procs (cgroupname, mem_controller , &pids, &size);
621
622
if (ret != 0 ) error (ret, " cgroup_get_procs" );
622
623
for (int i = 0 ; i < size; i++) {
623
624
kill (pids[i], SIGKILL);
@@ -628,7 +629,7 @@ void cgroup_kill()
628
629
while (1 ) {
629
630
void *handle = nullptr ;
630
631
pid_t pid;
631
- int ret = cgroup_get_task_begin (cgroupname, " memory " , &handle, &pid);
632
+ int ret = cgroup_get_task_begin (cgroupname, mem_controller , &handle, &pid);
632
633
cgroup_get_task_end (&handle);
633
634
if (ret == ECGEOF) break ;
634
635
kill (pid, SIGKILL);
0 commit comments