static void extract_cgroup(pid_t pid) { char *fname; if (asprintf(&fname, "/proc/%d/root%s/cgroup", pid, MNT_DIR) == -1) errExit("asprintf"); struct stat s; if (stat(fname, &s) == -1) return; // there is a cgroup file in MNT_DIR; load the information from the file load_cgroup(fname); free(fname); }
static void extract_cgroup(pid_t pid) { char *fname; if (asprintf(&fname, "/proc/%d/root%s", pid, RUN_CGROUP_CFG) == -1) errExit("asprintf"); struct stat s; if (stat(fname, &s) == -1) { free(fname); return; } // there is a cgroup file CGROUP_CFG, load it! load_cgroup(fname); free(fname); }