From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Thompson, David" Subject: Re: [PATCH] build: container: Use the same clone flags as fork(3). Date: Mon, 7 Sep 2015 13:19:53 -0400 Message-ID: References: <87twr84tlv.fsf@izanagi.i-did-not-set--mail-host-address--so-tickle-me> <87mvwyryw3.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:42894) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZ05G-00073L-J5 for guix-devel@gnu.org; Mon, 07 Sep 2015 13:19:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZZ05C-0002Yh-It for guix-devel@gnu.org; Mon, 07 Sep 2015 13:19:58 -0400 Received: from mail-yk0-f169.google.com ([209.85.160.169]:34730) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZ05C-0002YV-Fc for guix-devel@gnu.org; Mon, 07 Sep 2015 13:19:54 -0400 Received: by ykdg206 with SMTP id g206so86339869ykd.1 for ; Mon, 07 Sep 2015 10:19:54 -0700 (PDT) In-Reply-To: <87mvwyryw3.fsf@gnu.org> List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org To: =?UTF-8?Q?Ludovic_Court=C3=A8s?= Cc: guix-devel On Mon, Sep 7, 2015 at 12:13 PM, Ludovic Court=C3=A8s wrote: > David Thompson skribis: > >> This patch resolves an issue I was having when working with containers >> at the REPL, which means it probably presented undetected issues >> elsewhere. > > Calling =E2=80=98primitive-fork=E2=80=99 at the REPL is not very useful a= nyway since you > end up with two Guiles trying to read from the same tty. Yes, this is true, but it made it glaringly obvious that something was wron= g. (match (primitive-fork) (0 (primitive-exit 0)) (pid pid)) ; OK since it exits immediately (match (clone (logior CLONE_NEWUSER SIGCHLD)) (0 (primitive-exit 0)) (pid pid)) ; Broken REPL! >> From 61ebbe55f7f6d4d4eb42db957d6fc7b4eaf282a6 Mon Sep 17 00:00:00 2001 >> From: David Thompson >> Date: Sat, 5 Sep 2015 14:10:08 -0400 >> Subject: [PATCH] build: container: Use the same clone flags as fork(3). >> >> The intent is to make 'clone' behave a lot more like 'primitive-fork', w= hich >> calls clone(2) with SIGCHLD, CLONE_CHILD_CLEARTID, and CLONE_CHILD_SETTI= D >> flags. Notably, running 'clone' at the REPL without these flags would b= reak >> the REPL beyond repair. >> >> * guix/build/syscalls.scm (CLONE_CHILD_CLEARTID, CLONE_CHILD_SETTID): Ne= w >> variables. >> * gnu/build/linux-container.scm (namespaces->bit-mask): Add >> CLONE_CHILD_CLEARTID and CLONE_CHILD_SETTID to bit mask. > > Looking at clone(2) and libc, I=E2=80=99m guessing that without these fla= gs, the > child would have a wrong idea of its thread ID, which in turn may cause > all sorts of problems, right? Yes, that seems to be the case. I was always a little suspicious about not using the same clone flags as fork, and I finally ran into a case where it made a difference. > LGTM. Pushed, thanks! - Dave