On Mon, Jul 26, 2010 at 11:20 AM, Balbir Singh
<[email protected]> wrote:
> On Mon, Jul 26, 2010 at 2:34 PM, Dhaval Giani <[email protected]> wrote:
>> libcgroup: Get the list of procs
>>
>> This patch adds a new API to get a list of procs. This is
>> guaranteed to be sorted.
>>
>> TODO:
>> 1. Ensure only unique values make it through
>>
>> Signed-off-by: Dhaval Giani <[email protected]>
>> ---
>>  include/libcgroup/error.h  |    1
>>  include/libcgroup/groups.h |   10 +++++
>>  src/api.c                  |   87 
>> +++++++++++++++++++++++++++++++++++++++++++++
>>  src/libcgroup.map          |    7 +++
>>  4 files changed, 105 insertions(+)
>>
>> Index: libcg/src/api.c
>> ===================================================================
>> --- libcg.orig/src/api.c
>> +++ libcg/src/api.c
>> @@ -116,6 +116,7 @@ const char const *cgroup_strerror_codes[
>>        "Have multiple paths for the same namespace",
>>        "Controller in namespace does not exist",
>>        "Cannot have mount and namespace keyword in the same configuration 
>> file",
>> +       "Your kernel does not support this feature",
>
> Nit: I'd prefer changing this to, "This kernel" instead of "Your kernel"
>

Will do.

> Otherwise, seems reasonable, could you please post the test case (i'd
> really like to solve the n-- issue, it seems like you are doing an
> additional n++ or something is wrong with the test case) and add a
> TODO for procs iterator as well
>

I am attaching the test case, since I managed to mess up the patch and
still have not gotten aroudn to fixing it.

Dhaval
#include <stdio.h>
#include <libcgroup.h>
#include <stdlib.h>

/*
 * Assumes the cgroup is already mounted at /cgroup/memory/a
 *
 * Assumes some processes are already in the cgroup
 *
 * Assumes it is the memory controller is mounted in at that
 * point
 */
int main()
{
        int test;
        int size;
        pid_t *pids;
        int ret;
        int i;

        ret = cgroup_init();
        if (ret) {
                printf("FAIL: cgroup_init failed with %s\n", 
cgroup_strerror(ret));
                exit(3);
        }

        ret = cgroup_get_procs("a", "memory", &pids, &size);
        if (ret) {
                printf("FAIL: cgroup_get_procs failed with %s\n", 
cgroup_strerror(ret));
                exit(3);
        }

        for (i = 0; i < size; i++)
                printf("%u\n", pids[i]);

        return 0;
}
------------------------------------------------------------------------------
The Palm PDK Hot Apps Program offers developers who use the
Plug-In Development Kit to bring their C/C++ apps to Palm for a share 
of $1 Million in cash or HP Products. Visit us here for more details:
http://ad.doubleclick.net/clk;226879339;13503038;l?
http://clk.atdmt.com/CRS/go/247765532/direct/01/
_______________________________________________
Libcg-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/libcg-devel

Reply via email to