From: Weng Meiling <wengmeiling.w...@huawei.com>

All commands except cgdelete can display help info when cgroup
is not mounted. cgdelete command display like this:

$ lssubsys -m
$
$cgdelete -h
/usr/bin/cgdelete: libcgroup initialization failed: Cgroup is not mounted

This patch makes cgdelete command can display help info like other commands
when cgroup is not mounted.

Signed-off-by: Weng Meiling <wengmeiling.w...@huawei.com>
---
 src/tools/cgdelete.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/src/tools/cgdelete.c b/src/tools/cgdelete.c
index 190310f..cad7c0a 100644
--- a/src/tools/cgdelete.c
+++ b/src/tools/cgdelete.c
@@ -64,15 +64,6 @@ int main(int argc, char *argv[])
        struct cgroup *cgroup;
        struct cgroup_controller *cgc;

-       /* initialize libcg */
-       ret = cgroup_init();
-       if (ret) {
-               fprintf(stderr, "%s: "
-                       "libcgroup initialization failed: %s\n",
-                       argv[0], cgroup_strerror(ret));
-               goto err;
-       }
-
        cgroup_list = calloc(argc, sizeof(struct cgroup_group_spec *));
        if (cgroup_list == NULL) {
                fprintf(stderr, "%s: out of memory\n", argv[0]);
@@ -121,6 +112,15 @@ int main(int argc, char *argv[])
                }
        }

+       /* initialize libcg */
+       ret = cgroup_init();
+       if (ret) {
+               fprintf(stderr, "%s: "
+                       "libcgroup initialization failed: %s\n",
+                       argv[0], cgroup_strerror(ret));
+               goto err;
+       }
+
        /* for each cgroup to be deleted */
        for (i = 0; i < argc; i++) {
                if (!cgroup_list[i])
-- 
1.8.3



------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from 
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60135031&iu=/4140/ostg.clktrk
_______________________________________________
Libcg-devel mailing list
Libcg-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libcg-devel

Reply via email to