include/libcgroup/tasks.h File Reference

#include <libcgroup/groups.h>
#include <features.h>
#include <stdbool.h>

Enumerations

enum  cgflags { CGFLAG_USECACHE = 0x01 }
 

Flags for cgroup_change_cgroup_uid_gid().

More...
enum  cgroup_daemon_type { CGROUP_DAEMON_UNCHANGE_CHILDREN = 0x1 }
 

Flags for cgroup_register_unchanged_process().

More...

Simple task assignment

Applications can use following functions to simply put a task into given control group and find a groups where given tasks is.



int cgroup_attach_task (struct cgroup *cgroup)
 Move current task (=thread) to given control group.
int cgroup_attach_task_pid (struct cgroup *cgroup, pid_t tid)
 Move given task (=thread) to to given control group.
int cgroup_change_cgroup_path (const char *path, pid_t pid, const char *const controllers[])
 Changes the cgroup of a task based on the path provided.
int cgroup_get_current_controller_path (pid_t pid, const char *controller, char **current_path)
 Get the current control group path where the given task is.

Rules

libcgroup can move tasks to control groups using simple rules, loaded from configuration file.

See cgrules.conf man page to see format of the file. Following functions can be used to load these rules from a file.



int cgroup_init_rules_cache (void)
 Initializes the rules cache and load it from /etc/cgrules.conf.
int cgroup_reload_cached_rules (void)
 Reloads the rules list from /etc/cgrules.conf.
void cgroup_print_rules_config (FILE *fp)
 Print the cached rules table.

Rule based task assignment

libcgroup can move tasks to control groups using simple rules, loaded from configuration file.

See cgrules.conf man page to see format of the file. Applications can move tasks to control groups based on these rules using following functions.



int cgroup_change_cgroup_flags (uid_t uid, gid_t gid, const char *procname, pid_t pid, int flags)
 Changes the cgroup of a program based on the rules in the config file.
int cgroup_change_cgroup_uid_gid_flags (uid_t uid, gid_t gid, pid_t pid, int flags)
 Changes the cgroup of a program based on the rules in the config file.
int cgroup_change_cgroup_uid_gid (uid_t uid, gid_t gid, pid_t pid)
 Provides backwards-compatibility with older versions of the API.

Communication with cgrulesengd daemon

Users can use cgrulesengd daemon to move tasks to groups based on the rules automatically when they change their UID, GID or executable name.

The daemon allows tasks to be 'sticky', i.e. all rules are ignored for these tasks and the daemon never moves them.



int cgroup_register_unchanged_process (pid_t pid, int flags)
 Register the unchanged process to a cgrulesengd daemon.

Enumeration Type Documentation

enum cgflags

Flags for cgroup_change_cgroup_uid_gid().

Enumerator:
CGFLAG_USECACHE 

Use cached rules, do not read rules from disk.

Flags for cgroup_register_unchanged_process().

Enumerator:
CGROUP_DAEMON_UNCHANGE_CHILDREN 

The daemon must not touch the given task, i.e.

it never moves it to any controlgroup.


Generated on 31 Mar 2010 for libcgroup by  doxygen 1.6.1