From owner-freebsd-current@freebsd.org Thu Jul 7 07:32:09 2016 Return-Path: Delivered-To: freebsd-current@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 78EAFB2196C for ; Thu, 7 Jul 2016 07:32:09 +0000 (UTC) (envelope-from mailing-machine@vniz.net) Received: from mail-lf0-f52.google.com (mail-lf0-f52.google.com [209.85.215.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 09BD61A54 for ; Thu, 7 Jul 2016 07:32:08 +0000 (UTC) (envelope-from mailing-machine@vniz.net) Received: by mail-lf0-f52.google.com with SMTP id f6so5770350lfg.0 for ; Thu, 07 Jul 2016 00:32:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:subject:to:references:cc:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=rp2PWzViNTn2dxaIhWKfuSPG+jg9eEQjyzxatq+deAs=; b=lCWARU2pH6EdNERzz5lh8Kf7Snp6g0dyKggvMPx8ibmNG+Vjr9tOShP3xeCbY2fuEc cUlHpep3NNLRyZSUa9Cd/VfDz27WjH6BcspLMmFwZmVrxRP/MC3ONxR8gIYB9CMpUZml y/uHi0hz0SUvMCwcR2dfjxQqVecuz/mo7hywul5qlXIejaaipPd9TTituOntYLwVa1/4 lRL2VEO2AjQaxy4OKg6gpuGr02o2fcYy4leyd7kdV5nRix8AQCL6VrpyyIh+cqdhXGDJ Kg+/piUyxWkoGZeBLyTLUwyR2ok+hX0CQGqvRw2LBgqoZBE/GkXkRvmKQkrXe9kD4zBZ mqxg== X-Gm-Message-State: ALyK8tJsldHXde+F1jl32YhL2iDVINvo+GODMO40CPxj/bSUygHQhzJBeEvaI+598+Djuw== X-Received: by 10.25.21.106 with SMTP id l103mr6391802lfi.27.1467876726567; Thu, 07 Jul 2016 00:32:06 -0700 (PDT) Received: from [192.168.1.2] ([89.169.173.68]) by smtp.gmail.com with ESMTPSA id a199sm750772lfe.35.2016.07.07.00.32.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Jul 2016 00:32:06 -0700 (PDT) Subject: Re: difference in SIGCHLD behavior between Linux and FreeBSD breaks apt To: Don Lewis , mmacy@nextbsd.org References: <201607070714.u677EqVx008159@gw.catspoiler.org> Cc: freebsd-hackers@freebsd.org, freebsd-current@freebsd.org, kmacy@freebsd.org From: Andrey Chernov Message-ID: <325f545e-a32d-59d8-86d3-079ecdf21df2@freebsd.org> Date: Thu, 7 Jul 2016 10:32:05 +0300 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 MIME-Version: 1.0 In-Reply-To: <201607070714.u677EqVx008159@gw.catspoiler.org> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 07 Jul 2016 07:32:09 -0000 On 07.07.2016 10:14, Don Lewis wrote: > On 6 Jul, Matthew Macy wrote: >> >> >> >> ---- On Wed, 06 Jul 2016 23:48:53 -0700 Andrey Chernov >> wrote ---- >> > On 07.07.2016 9:40, Matthew Macy wrote: >> > > >> > > >> > > >> > > ---- On Wed, 06 Jul 2016 23:28:40 -0700 Andrey Chernov >> > > wrote ---- >> > > > On 07.07.2016 7:52, K. Macy wrote: >> > > > > On Wednesday, July 6, 2016, Don Lewis >> > > > > wrote: >> > > > > >> > > > >> On 6 Jul, Matthew Macy wrote: >> > > > >>> As a first step towards managing linux user space in a >> > > > >>> chrooted >> > > > >>> /compat/linux, initially for i915 testing with intel gpu >> > > > >>> tools, later on to get widevine and steam to work I'm >> > > > >>> trying to get apt to work. I've fixed a number of issues >> > > > >>> to date in pseudofs/linprocfs but now I'm running in to >> > > > >>> a bug caused by differences in SIGCHLD handling between >> > > > >>> Linux and FreeBSD. The situation is that apt will spawn >> > > > >>> dpkg and wait on a pipe read. On Linux when dpkg exits >> > > > >>> the SIGCHLD to apt causes a short read on the pipe >> > > > >>> which lets apt then continue. On FreeBSD a SIGCHLD is >> > > > >>> silently ignored. I've even experimented with doing a >> > > > >>> kill -20 to no effect. >> > > > >>> >> > > > >>> It would be easy enough to check sysvec against linux in >> > > > >>> pipe_read and break out of the loop when it's awakened >> > > > >>> from msleep (assuming there aren't deeper issues with >> > > > >>> signal propagation for anything other than >> > > > >>> SIGINT/SIGKILL) and then do a short read. However, I'm >> > > > >>> assuming that anyone who has worked in this area >> > > > >>> probably has a cleaner solution. >> > > > >> >> > > > >> It shoulds like SA_RESTART is set in sa_flags for SIGCHLD >> > > > >> but shouldn't be in this case. >> > > > > >> > > > > >> > > > > >> > > > > Good point. >> > > > > >> > > > > Thinking more about it, this seems like a bug in FreeBSD. >> > > > > Not a valid behavioral difference. >> > > > >> > > > You better need consult with POSIX before fixing things toward >> > > > any Linuxisms blindly in our native code. I don't have a >> > > > time now to see, is it really a bug according to POSIX, but >> > > > please read or just find all SIGCHLD there: >> > > > http://pubs.opengroup.org/onlinepubs/9699919799/functions/wait.html >> > > > it explain SIGCHLD actions in deep details. >> > > > And that one too: >> > > > http://pubs.opengroup.org/onlinepubs/009695399/functions/sigaction.html >> > > >> > > >> > > >> > > I was pretty clear in my initial email that I'm only interested >> > > in changing behavior for Linux programs. >> > >> > Of course, but in case it is FreeBSD bug, it should be fixed in our >> > native code first before making any changes in Linuxator. >> > >> > > And I was asking for help with that, not a link to SUSv3 or POSIX. >> > >> > In case I was not helpful, sorry for that. Before you try to change >> > something in Linuxator you need to be sure that FreeBSD does it >> > right (or wrong, then fix FreeBSD native code first). I am just >> > insisting on proper steps of fixing it. >> > >> >> >> I'm sorry for snapping . I misunderstood your intent. Using a SIGCHLD >> to deliberately interrupt a pipe read is such a weird idiom. I'll test >> fork vs clone on Linux and see how OS X responds to a SIGCHLD during a >> pipe read. > > It really depends on how signal handling has been set up. From my > understanding of the FreeBSD man pages and the Open Group documents, the > default handling for SIGCHLD is to just ignore it, in which case it > shouldn't interrupt the pipe read. If the process has set up a SIGCHLD > signal handler, then what happens with the read should depend on whether > or not SA_RESTART was passed to sigaction(). I would expect that Linux > would be the same as FreeBSD and the Open Group specs. Linux as SysV derivative was always different regarding to SA_RESTART and other SA_* flags for signal(), see differences at the end of: http://linux.die.net/man/2/signal