@@ -375,8 +375,6 @@ Run COMMAND with restrictions.\n\
375
375
Note that root privileges are needed for the `root' and `user' options.\n\
376
376
If `user' is set, then `group' defaults to the same to prevent security\n\
377
377
issues, since otherwise the process would retain group root permissions.\n\
378
- Additionally, Linux cgroup support is required for the `memsize', `cpuset'\n\
379
- and `cputime' options, and to report actual memory usage.\n\
380
378
The COMMAND path is relative to the changed ROOT directory if specified.\n\
381
379
TIME may be specified as a float; two floats separated by `:' are treated\n\
382
380
as soft and hard limits. The runtime written to file is that of the last\n\
@@ -444,22 +442,10 @@ void output_exit_time(int exitcode, double cpudiff)
444
442
write_meta ("time-result" ,"%s" ,output_timelimit_str [timelimit_reached ]);
445
443
}
446
444
447
- /* Return whether we need to use cgroups. This is checked in the
448
- * cgroup_* functions below. If not used they return without
449
- * performing any action.
450
- */
451
- int use_cgroup ()
452
- {
453
- return use_cputime || memsize != RLIM_INFINITY ||
454
- ( cpuset != NULL && strlen (cpuset )> 0 );
455
- }
456
-
457
445
void check_remaining_procs ()
458
446
{
459
447
char path [1024 ];
460
448
461
- if ( !use_cgroup () ) return ;
462
-
463
449
snprintf (path , 1023 , "/sys/fs/cgroup/cpuacct%scgroup.procs" , cgroupname );
464
450
FILE * file = fopen (path , "r" );
465
451
if (file == NULL ) {
@@ -480,8 +466,6 @@ void output_cgroup_stats(double *cputime)
480
466
struct cgroup * cg ;
481
467
struct cgroup_controller * cg_controller ;
482
468
483
- if ( !use_cgroup () ) return ;
484
-
485
469
if ( (cg = cgroup_new_cgroup (cgroupname ))== NULL ) error (0 ,"cgroup_new_cgroup" );
486
470
if ((ret = cgroup_get_cgroup (cg )) != 0 ) error (ret ,"get cgroup information" );
487
471
@@ -512,8 +496,6 @@ void cgroup_create()
512
496
struct cgroup * cg ;
513
497
struct cgroup_controller * cg_controller ;
514
498
515
- if ( !use_cgroup () ) return ;
516
-
517
499
cg = cgroup_new_cgroup (cgroupname );
518
500
if (!cg ) error (0 ,"cgroup_new_cgroup" );
519
501
@@ -560,8 +542,6 @@ void cgroup_attach()
560
542
int ret ;
561
543
struct cgroup * cg ;
562
544
563
- if ( !use_cgroup () ) return ;
564
-
565
545
cg = cgroup_new_cgroup (cgroupname );
566
546
if (!cg ) error (0 ,"cgroup_new_cgroup" );
567
547
@@ -579,8 +559,6 @@ void cgroup_kill()
579
559
void * handle = NULL ;
580
560
pid_t pid ;
581
561
582
- if ( !use_cgroup () ) return ;
583
-
584
562
/* kill any remaining tasks, and wait for them to be gone */
585
563
while (1 ) {
586
564
ret = cgroup_get_task_begin (cgroupname , "memory" , & handle , & pid );
@@ -595,8 +573,6 @@ void cgroup_delete()
595
573
int ret ;
596
574
struct cgroup * cg ;
597
575
598
- if ( !use_cgroup () ) return ;
599
-
600
576
cg = cgroup_new_cgroup (cgroupname );
601
577
if (!cg ) error (0 ,"cgroup_new_cgroup" );
602
578
@@ -1198,11 +1174,9 @@ int main(int argc, char **argv)
1198
1174
}
1199
1175
}
1200
1176
/* Make libcgroup ready for use */
1201
- if ( use_cgroup () ) {
1202
- ret = cgroup_init ();
1203
- if ( ret != 0 ) {
1204
- error (0 ,"libcgroup initialization failed: %s(%d)\n" , cgroup_strerror (ret ), ret );
1205
- }
1177
+ ret = cgroup_init ();
1178
+ if ( ret != 0 ) {
1179
+ error (0 ,"libcgroup initialization failed: %s(%d)\n" , cgroup_strerror (ret ), ret );
1206
1180
}
1207
1181
/* Define the cgroup name that we will use and make sure it will
1208
1182
* be unique. Note: group names must have slashes!
0 commit comments