From: "Paul Menage" <menage@google.com>
To: "Matt Helsley" <matthltc@us.ibm.com>
Cc: "Dhaval Giani" <dhaval@linux.vnet.ibm.com>,
"Andrea Righi" <righi.andrea@gmail.com>,
"Li Zefan" <lizf@cn.fujitsu.com>,
lkml <linux-kernel@vger.kernel.org>,
"Sudhir Kumar" <skumar@linux.vnet.ibm.com>,
containers@lists.osdl.org,
"Andrew Morton" <akpm@linux-foundation.org>
Subject: Re: Attaching PID 0 to a cgroup
Date: Thu, 3 Jul 2008 15:03:05 -0700 [thread overview]
Message-ID: <6599ad830807031503s6c7f3d5fu3bf65d5a944f5c17@mail.gmail.com> (raw)
In-Reply-To: <1215122375.14808.180.camel@localhost.localdomain>
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
prev parent reply other threads:[~2008-07-03 22:03 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-07-01 9:45 Dhaval Giani
2008-07-01 9:47 ` Dhaval Giani
2008-07-01 10:28 ` Li Zefan
2008-07-01 10:51 ` Dhaval Giani
2008-07-01 18:54 ` Paul Jackson
2008-07-01 19:01 ` Paul Menage
2008-07-01 21:48 ` Andrea Righi
2008-07-01 21:54 ` Dhaval Giani
2008-07-03 21:59 ` Matt Helsley
2008-07-03 22:03 ` Paul Menage [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=6599ad830807031503s6c7f3d5fu3bf65d5a944f5c17@mail.gmail.com \
--to=menage@google.com \
--cc=akpm@linux-foundation.org \
--cc=containers@lists.osdl.org \
--cc=dhaval@linux.vnet.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lizf@cn.fujitsu.com \
--cc=matthltc@us.ibm.com \
--cc=righi.andrea@gmail.com \
--cc=skumar@linux.vnet.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®