diff options
author | Balbir Singh <balbir@linux.vnet.ibm.com> | 2008-08-22 22:34:50 +0000 |
---|---|---|
committer | Balbir Singh <balbir@linux.vnet.ibm.com> | 2008-08-22 22:34:50 +0000 |
commit | 137549382fba5ff7fa874e787226a7f3e3f9d9f4 (patch) | |
tree | a2ca680f984df3b96e6be86100f012ca8e6550b9 /tests/libcg_ba.cpp | |
parent | 2124f1ea16bcc12482928c45689c1fa4d92a74a1 (diff) | |
download | libcg-137549382fba5ff7fa874e787226a7f3e3f9d9f4.tar.gz libcg-137549382fba5ff7fa874e787226a7f3e3f9d9f4.tar.xz libcg-137549382fba5ff7fa874e787226a7f3e3f9d9f4.zip |
More fixes to the earlier attempt to create new cgroup inheriting parent's
attributes. Test cases have also been updated.
Tested on an x86_64 box with libcg_ba
Signed-off-by: Balbir Singh <balbir@linux.vnet.ibm.com>
git-svn-id: https://libcg.svn.sourceforge.net/svnroot/libcg/trunk@166 4f4bb910-9a46-0410-90c8-c897d4f1cd53
Diffstat (limited to 'tests/libcg_ba.cpp')
-rw-r--r-- | tests/libcg_ba.cpp | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/tests/libcg_ba.cpp b/tests/libcg_ba.cpp index 99a9184..6d402b6 100644 --- a/tests/libcg_ba.cpp +++ b/tests/libcg_ba.cpp @@ -86,8 +86,7 @@ struct cgroup *cg::makenode(const string &name, const string &task_uid, dbg("tuid %d, tgid %d, cuid %d, cgid %d\n", tuid, tgid, cuid, cgid); cgroup_name = (char *) malloc(name.length()); - memset(cgroup_name, '\0', name.length()); - strncpy(cgroup_name, name.c_str(), name.length()); + strncpy(cgroup_name, name.c_str(), name.length() + 1); ccg = cgroup_new_cgroup(cgroup_name); cgroup_set_uid_gid(ccg, tuid, tgid, cuid, cgid); @@ -135,12 +134,14 @@ int main(int argc, char *argv[]) { try { cg *app = new cg(); - struct cgroup *ccg, *ccg_child; + struct cgroup *ccg, *ccg_child1, *ccg_child2; ccg = app->makenode("database", "root", "root", "balbir", "balbir"); - ccg_child = app->makenodefromparent("mysql"); + ccg_child1 = app->makenodefromparent("mysql"); + ccg_child2 = app->makenodefromparent("mysql/db1"); cgroup_free(&ccg); - cgroup_free(&ccg_child); + cgroup_free(&ccg_child1); + cgroup_free(&ccg_child2); delete app; } catch (exception &e) { cout << e.what() << endl; |