cgroup-setup: add fd-based version of cg_attach()
This commit is contained in:
@@ -384,6 +384,20 @@ int cg_attach(const char *controller, const char *path, pid_t pid) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int cg_fd_attach(int fd, pid_t pid) {
|
||||
char c[DECIMAL_STR_MAX(pid_t) + 2];
|
||||
|
||||
assert(fd >= 0);
|
||||
assert(pid >= 0);
|
||||
|
||||
if (pid == 0)
|
||||
pid = getpid_cached();
|
||||
|
||||
xsprintf(c, PID_FMT "\n", pid);
|
||||
|
||||
return write_string_file_at(fd, "cgroup.procs", c, WRITE_STRING_FILE_DISABLE_BUFFER);
|
||||
}
|
||||
|
||||
int cg_attach_fallback(const char *controller, const char *path, pid_t pid) {
|
||||
int r;
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ int cg_trim(const char *controller, const char *path, bool delete_root);
|
||||
|
||||
int cg_create(const char *controller, const char *path);
|
||||
int cg_attach(const char *controller, const char *path, pid_t pid);
|
||||
int cg_fd_attach(int fd, pid_t pid);
|
||||
int cg_attach_fallback(const char *controller, const char *path, pid_t pid);
|
||||
int cg_create_and_attach(const char *controller, const char *path, pid_t pid);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user