OpenVZ Forum


Home » Mailing lists » Devel » Re: Attaching PID 0 to a cgroup
Re: Attaching PID 0 to a cgroup [message #31579 is a reply to message #31578] Thu, 03 July 2008 22:03 Go to previous message
Paul Menage is currently offline  Paul Menage
Messages: 642
Registered: September 2006
Senior Member
On Thu, Jul 3, 2008 at 2:59 PM, Matt Helsley <matthltc@us.ibm.com> wrote:
> ------------
>        char buffer[16];
>        int fd;
>
>        fd = open("/some/cgroup/tasks", O_WRONLY);
>
>        /*
>         * These two writes produce the same effect: adding this process
>         * to /some/cgroup.
>         */
>        if (the_slightly_shorter_way)
>                write(fd, "0", 2);
>        else {
>                /* The slightly-less-short way */
>                snprintf(buffer, 16, "%u", getpid());
>                write(fd, buffer, strlen(buffer));

If it's a threaded application, then you'd need gettid() rather than
getpid() for the two to be equivalent.

Paul
_______________________________________________
Containers mailing list
Containers@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/containers
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: [PATCH -mmotm] res_counter: fix building failure
Next Topic: [PATCH 02/15] sysfs: Support for preventing unmounts.
Goto Forum:
  


Current Time: Wed Jul 23 13:53:59 GMT 2025

Total time taken to generate the page: 0.14253 seconds