@@ -144,7 +144,7 @@ bool is_cgroup_v2 = false;
144144
145145double walltimelimit[2 ], cputimelimit[2 ]; /* in seconds, soft and hard limits */
146146int walllimit_reached, cpulimit_reached; /* 1=soft, 2=hard, 3=both limits reached */
147- int64_t memsize;
147+ rlim_t memsize;
148148rlim_t filesize;
149149rlim_t nproc;
150150size_t streamsize;
@@ -550,15 +550,15 @@ void cgroup_create()
550550 if (is_cgroup_v2) {
551551 // TODO: do we want to set cpu.weight here as well?
552552 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 );
555555 } else {
556556 cgroup_add_value (string, " memory.max" , " max" );
557557 cgroup_add_value (string, " memory.swap.max" , " max" );
558558 }
559559 } 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);
562562 }
563563
564564 /* Set up cpu restrictions; we pin the task to a specific set of
@@ -613,11 +613,12 @@ void cgroup_attach()
613613void cgroup_kill ()
614614{
615615 /* kill any remaining tasks, and wait for them to be gone */
616+ char mem_controller[10 ] = " memory" ;
616617 if (is_cgroup_v2) {
617618 int size;
618619 do {
619620 pid_t * pids;
620- int ret = cgroup_get_procs (cgroupname, " memory " , &pids, &size);
621+ int ret = cgroup_get_procs (cgroupname, mem_controller , &pids, &size);
621622 if (ret != 0 ) error (ret, " cgroup_get_procs" );
622623 for (int i = 0 ; i < size; i++) {
623624 kill (pids[i], SIGKILL);
@@ -628,7 +629,7 @@ void cgroup_kill()
628629 while (1 ) {
629630 void *handle = nullptr ;
630631 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);
632633 cgroup_get_task_end (&handle);
633634 if (ret == ECGEOF) break ;
634635 kill (pid, SIGKILL);
0 commit comments