From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752992Ab0CYVv4 (ORCPT ); Thu, 25 Mar 2010 17:51:56 -0400 Received: from e208.rev.megiteam.pl ([77.79.226.8]:52360 "EHLO vadmin.megiteam.com.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752097Ab0CYVvy (ORCPT ); Thu, 25 Mar 2010 17:51:54 -0400 X-Greylist: delayed 1075 seconds by postgrey-1.27 at vger.kernel.org; Thu, 25 Mar 2010 17:51:54 EDT Date: Thu, 25 Mar 2010 22:33:56 +0100 From: Grzegorz Nosek To: Matt Helsley Cc: Roland McGrath , Oleg Nesterov , Sukadev Bhattiprolu , containers@lists.linux-foundation.org, linux-kernel@vger.kernel.org Subject: Re: Testing lxc 0.6.5 in Fedora 13 Message-ID: <20100325213356.GB20541@megiteam.pl> References: <20100321195044.GA23757@megiteam.pl> <20100323212834.GH20796@count0.beaverton.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20100323212834.GH20796@count0.beaverton.ibm.com> User-Agent: Mutt/1.5.13 (2006-08-11) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On wto, mar 23, 2010 at 02:28:34 -0700, Matt Helsley wrote: > On Sun, Mar 21, 2010 at 08:50:44PM +0100, Grzegorz Nosek wrote: > > > > > 2. Weird strace behaviour across pidns boundary > > > > When strace'ing (with -ff) lxc-start, I get a proper strace for the > > directly spawned process and the container init. However, any processes > > spawned by the container's init are not straced properly (I get two > > empty files, named . and .2 -- presumably pid > > inside the container). The container also seems to malfunction under > > strace (looks like exec() failing as lxc-ps shows two "init" processes). > > > > This is quite painful as it prevents strace'ing processes in containers > > even after startup. Here's a snippet of strace'ing a bash (pid 179 > > inside, pid 2959 outside) trying to run 'ls'. The shell hangs until I > > kill the strace process. > > > > pipe([3, 4]) = 0 > > clone(Process 197 attached > > child_stack=0, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0xb7859708) = 197 > > Process 2999 attached (waiting for parent) > > [pid 2959] setpgid(197, 197) = 0 > > [pid 2959] rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0 > > [pid 2959] rt_sigprocmask(SIG_BLOCK, [CHLD], [], 8) = 0 > > [pid 2959] close(3) = 0 > > [pid 2959] close(4) = 0 > > [pid 2959] rt_sigprocmask(SIG_BLOCK, [CHLD TSTP TTIN TTOU], [CHLD], 8) = 0 > > [pid 2959] ioctl(255, TIOCSPGRP, [197]) = 0 > > [pid 2959] rt_sigprocmask(SIG_SETMASK, [CHLD], NULL, 8) = 0 > > [pid 2959] rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0 > > [pid 2959] rt_sigprocmask(SIG_BLOCK, [CHLD], [], 8) = 0 > > [pid 2959] waitpid(-1, Process 2959 suspended > > ^C > > Process 2959 detached > > Process 197 detached > > Process 2999 detached > > > > 'strace ls' ran completely inside the container works as expected. > > I'm suprised strace of ls works across pid namespaces. I've been looking > at strace and it seemed to me that one kernel change and a bunch of strace > changes are needed to make strace'ing in child pid namespaces work. Eric > Biederman's setns() patches also might help. Thanks for the patch and the detailed explanation. > Can you get a little farther with the kernel fix below? No, not really. Attaching from outside to a shell running in a container and running a command yields: | rt_sigprocmask(SIG_BLOCK, [INT CHLD], [], 8) = 0 | pipe([3, 4]) = 0 | clone(Process 2581 attached (waiting for parent) | Process 190 attached Without the patch the order of reported pids is reversed (and at least with the patched kernel the outside pid is consistently reported first) | child_stack=0, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0xb7713708) = 190 | [pid 2549] setpgid(190, 190) = 0 | [pid 2549] rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0 | [pid 2549] rt_sigprocmask(SIG_BLOCK, [CHLD], [], 8) = 0 | [pid 2549] close(3) = 0 | [pid 2549] close(4) = 0 | [pid 2549] rt_sigprocmask(SIG_BLOCK, [CHLD TSTP TTIN TTOU], [CHLD], 8) = 0 | [pid 2549] ioctl(255, TIOCSPGRP, [190]) = 0 | [pid 2549] rt_sigprocmask(SIG_SETMASK, [CHLD], NULL, 8) = 0 | [pid 2549] rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0 | [pid 2549] rt_sigprocmask(SIG_BLOCK, [CHLD], [], 8) = 0 | [pid 2549] waitpid(-1, Process 2549 suspended (the shell hangs here) ^C | Process 2549 detached | Process 2581 detached | Process 190 detached (the command executes here normally). Best regards, Grzegorz Nosek