Skip to content

Commit fa76562

Browse files
committed
libcgroup 2.0.2
1 parent 8a96073 commit fa76562

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

judge/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ evict: evict.c $(LIBHEADERS) $(LIBSOURCES)
1818

1919
LIBCGROUP_DIR = lib/libcgroup-3.1.0
2020
runguard: runguard.cc $(LIBHEADERS) $(LIBSOURCES) $(TOPDIR)/etc/runguard-config.h
21-
$(CXX) $(CXXFLAGS) -L$(TOPDIR)/$(LIBCGROUP_DIR)/src/.libs -I$(TOPDIR)/$(LIBCGROUP_DIR)/include -o $@ $< $(LIBSOURCES) -lcgroup -Wl,-rpath,$(abspath $(TOPDIR))/$(LIBCGROUP_DIR)/src/.libs
21+
$(CXX) $(CXXFLAGS) -o $@ $< $(LIBSOURCES) -lcgroup
2222

2323
runpipe: runpipe.cc $(LIBHEADERS) $(LIBSOURCES)
2424
$(CXX) $(CXXFLAGS) -static -o $@ $< $(LIBSOURCES)

judge/runguard.cc

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,7 @@ void cgroup_kill()
610610
int size;
611611
do {
612612
pid_t* pids;
613-
int ret = cgroup_get_procs(cgroupname, NULL, &pids, &size);
613+
int ret = cgroup_get_procs(cgroupname, "memory", &pids, &size);
614614
if (ret != 0) error(ret, "cgroup_get_procs");
615615
for(int i = 0; i < size; i++) {
616616
kill(pids[i], SIGKILL);
@@ -646,8 +646,9 @@ void cgroup_delete()
646646
}
647647
/* Clean up our cgroup */
648648
nanosleep(&cg_delete_delay,nullptr);
649-
int ret = cgroup_delete_cgroup_ext(cg, CGFLAG_DELETE_IGNORE_MIGRATION | CGFLAG_DELETE_RECURSIVE);
650-
if ( ret!=0 ) error(ret,"deleting cgroup");
649+
int ret = cgroup_delete_cgroup_ext(cg, CGFLAG_DELETE_IGNORE_MIGRATION | CGFLAG_DELETE_RECURSIVE);
650+
// TODO: is this actually benign?
651+
if ( ret!=0 && ret!=ECGOTHER ) error(ret,"deleting cgroup");
651652

652653
cgroup_free(&cg);
653654

@@ -862,7 +863,8 @@ void setrestrictions()
862863

863864
/* Put the child process in the cgroup */
864865
if (is_cgroup_v2) {
865-
if (cgroup_change_cgroup_path(cgroupname, getpid(), NULL) != 0) {
866+
const char *controllers[] = { "cpu", "memory", "cpuset", NULL };
867+
if (cgroup_change_cgroup_path(cgroupname, getpid(), controllers) != 0) {
866868
error(0, "Failed to move the process to the cgroup");
867869
}
868870
} else {
@@ -1351,6 +1353,7 @@ int main(int argc, char **argv)
13511353
error(errno,"cannot start `%s'",cmdname);
13521354

13531355
default: /* become watchdog */
1356+
verbose("child pid = %d", child_pid);
13541357
/* Shed privileges, only if not using a separate child uid,
13551358
because in that case we may need root privileges to kill
13561359
the child process. Do not use Linux specific setresuid()

0 commit comments

Comments
 (0)