On Wed, Apr 22, 2009 at 02:32:06PM +0530, Bharata B Rao wrote:
> On Wed, Apr 22, 2009 at 02:16:43PM +0530, Dhaval Giani wrote:
> > Add a new API to iterate through the tasks file to get
> > the list of all the tasks in a cgroup.
> > 
> > Signed-off-by: Dhaval Giani <[email protected]>
> > 
> > ---
> >  include/libcgroup.h |   19 ++++++++++++++
> >  src/api.c           |   69 
> > ++++++++++++++++++++++++++++++++++++++++++++++++++++
> >  src/libcgroup.map   |    6 ++++
> >  3 files changed, 94 insertions(+)
> > 
> > Index: libcg/include/libcgroup.h
> > ===================================================================
> > --- libcg.orig/include/libcgroup.h
> > +++ libcg/include/libcgroup.h
> > @@ -274,6 +274,25 @@ int cgroup_read_stats_next(void **handle
> > 
> >  int cgroup_read_stats_end(void **handle);
> > 
> > +/**
> > + * Read the tasks file to get the list of tasks in a cgroup
> > + * @cgroup: Name of the cgroup
> > + * @controller: Name of the cgroup subsystem
> > + * @handle: Handle to be used in the iteration
> > + * @pid: The pid read from the tasks file. Will be filled in by the API
> > + */
> > +int cgroup_get_task_begin(char *cgroup, char *controller, void **handle,
> > +                                                           pid_t *pid);
> > +
> > +/**
> > + * Read the next task value
> > + * @handle: The handle used for iterating
> > + * @pid: The variable where the value will be stored
> > + *
> > + * return ECGEOF when the iterator finishes getting the list of tasks.
> > + */
> > +int cgroup_get_task_next(void *handle, pid_t *pid);
> > +int cgroup_get_task_end(void *handle);
> >  /* The wrappers for filling libcg structures */
> > 
> >  struct cgroup *cgroup_new_cgroup(const char *name);
> > Index: libcg/src/api.c
> > ===================================================================
> > --- libcg.orig/src/api.c
> > +++ libcg/src/api.c
> > @@ -2407,3 +2407,72 @@ int cgroup_read_stats_begin(char *contro
> >     *handle = fp;
> >     return ret;
> >  }
> > +
> > +int cgroup_get_task_end(void *handle)
> > +{
> > +   if (!cgroup_initialized)
> > +           return ECGROUPNOTINITIALIZED;
> > +
> > +   if (!handle)
> > +           return ECGINVAL;
> > +
> > +   fclose((FILE *) handle);
> > +   handle = NULL;
> 
> No use setting handle to NULL here. It will be not be reflected in the caller.
> You may want to pass double pointer if want to ensure that.

Good point. I am just removing that from here. Let the caller handle it
:)

thanks,
-- 
regards,
Dhaval

------------------------------------------------------------------------------
Stay on top of everything new and different, both inside and 
around Java (TM) technology - register by April 22, and save
$200 on the JavaOne (SM) conference, June 2-5, 2009, San Francisco.
300 plus technical and hands-on sessions. Register today. 
Use priority code J9JMT32. http://p.sf.net/sfu/p
_______________________________________________
Libcg-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/libcg-devel

Reply via email to