[lxc-devel] [Lxc-devel] [PATCH 3/5] Add pids of lxc-attach to the cgroup of container

"Axel Schöner" axel.schoener at gmx.de
Sun Oct 2 18:14:37 UTC 2011


--- lxc_roh/src/lxc/cgroup.c	2011-10-02 19:46:44.000000000 +0200
+++ lxc/src/lxc/cgroup.c	2011-10-02 19:13:44.000000000 +0200
@@ -270,36 +270,36 @@
  */
 int lxc_cgroup_append_task(const char *name, pid_t pid)
 {
-       struct mntent *mntent;
-       FILE *file = NULL;
-       int err = -1;
-       char cgname[MAXPATHLEN];
-
-       file = setmntent(MTAB, "r");
-       if (!file) {
-               SYSERROR("failed to open %s", MTAB);
-               return -1;
-       }
-
-       while ((mntent = getmntent(file))) {
-
-               DEBUG("checking '%s' (%s)", mntent->mnt_dir, mntent->mnt_type);
-
-               if (!strcmp(mntent->mnt_type, "cgroup")) {
-
-                       INFO("found cgroup mounted at '%s'", mntent->mnt_dir);
-                       snprintf(cgname, MAXPATHLEN, "%s/%s", mntent->mnt_dir, name);
-                       /* Let's add the pid to the 'tasks' file */
-                       err = cgroup_attach(cgname, pid);
-                       if (err) {
-                               SYSERROR("failed to attach pid '%d' to '%s'", pid, cgname);
-                               endmntent(file);
-                               return err;
-                       }
-               }
-       }
-       endmntent(file);
-       return err;
+	struct mntent *mntent;
+	FILE *file = NULL;
+	int err = -1;
+	char cgname[MAXPATHLEN];
+
+	file = setmntent(MTAB, "r");
+	if (!file) {
+		SYSERROR("failed to open %s", MTAB);
+		return -1;
+	}
+
+	while ((mntent = getmntent(file))) {
+
+		DEBUG("checking '%s' (%s)", mntent->mnt_dir, mntent->mnt_type);
+
+		if (!strcmp(mntent->mnt_type, "cgroup")) {
+
+			INFO("found cgroup mounted at '%s'", mntent->mnt_dir);
+			snprintf(cgname, MAXPATHLEN, "%s/%s", mntent->mnt_dir, name);
+			/* Let's add the pid to the 'tasks' file */
+			err = cgroup_attach(cgname, pid);
+			if (err) {
+				SYSERROR("failed to attach pid '%d' to '%s'", pid, cgname);
+				endmntent(file);
+				return err;
+			}
+		}
+	}
+	endmntent(file);
+	return err;
 }
-------------- next part --------------
A non-text attachment was scrubbed...
Name: patch_attach_cgroup_3of5_cgroup.c
Type: text/x-csrc
Size: 2018 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20111002/4710a664/attachment.c>


More information about the lxc-devel mailing list