'Sets cgroup membership
:param pid: pid of the process
:param pwd: cgroup directory'

def set_cgroup(self, pid, pwd=None):

    if (pwd is None):
        pwd = self.root
    if isinstance(pwd, int):
        pwd = self.cgroups[pwd]
    try:
        open(os.path.join(pwd, 'tasks'), 'w').write(str(pid))
    except Exception as inst:
        raise error.TestError(('cg.set_cgroup():    %s' % inst))
    if self.is_cgroup(pid, pwd):
        raise error.TestError(('cg.set_cgroup():    Setting    %d    pid    into    %s    cgroup    failed' % (pid, pwd)))
