Linux Container Development
 help / color / mirror / Atom feed
* [PATCH user-cr] use syscall(NR_getpid) to avoid cached pid
@ 2010-02-17  0:24 Serge E. Hallyn
       [not found] ` <20100217002409.GA3267-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
  0 siblings, 1 reply; 2+ messages in thread
From: Serge E. Hallyn @ 2010-02-17  0:24 UTC (permalink / raw)
  To: Oren Laadan; +Cc: Linux Containers

otherwise glibc caches getpid() result and we put the parent
process in the new cgroup, in the case of 'nsexec -cg /bin/sleep 10'

Signed-off-by: Serge Hallyn <serue-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
---
 nsexec.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/nsexec.c b/nsexec.c
index 3a825f1..79fcc70 100644
--- a/nsexec.c
+++ b/nsexec.c
@@ -154,7 +154,7 @@ int move_to_new_cgroup(int newcgroup)
 	fout = fopen(tasksfname, "w");
 	if (!fout)
 		return 0;
-	fprintf(fout, "%d\n", getpid());
+	fprintf(fout, "%d\n", syscall(__NR_getpid));
 	fclose(fout);
 	return 1;
 }
@@ -193,7 +193,7 @@ int do_child(void *vargv)
 
 	/* if pid == 1 then remount /proc */
 	/* But if the container has no /proc don't fret */
-	if (getpid() == 1) {
+	if (syscall(__NR_getpid) == 1) {
 		umount2("/proc", MNT_DETACH);
 		mount("proc", "/proc", "proc", 0, NULL);
 	}
-- 
1.6.4.4

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-02-18  0:57 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-02-17  0:24 [PATCH user-cr] use syscall(NR_getpid) to avoid cached pid Serge E. Hallyn
     [not found] ` <20100217002409.GA3267-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2010-02-18  0:57   ` Oren Laadan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox