From owner-freebsd-current@freebsd.org Wed Aug 9 19:46:52 2017 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 6D47BDD4BB6 for ; Wed, 9 Aug 2017 19:46:52 +0000 (UTC) (envelope-from bdrewery@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2610:1c1:1:6074::16:84]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "freefall.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 3D3E583C88; Wed, 9 Aug 2017 19:46:52 +0000 (UTC) (envelope-from bdrewery@FreeBSD.org) Received: from mail.xzibition.com (unknown [127.0.1.132]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by freefall.freebsd.org (Postfix) with ESMTPS id 3D23F13533; Wed, 9 Aug 2017 19:46:51 +0000 (UTC) (envelope-from bdrewery@FreeBSD.org) Received: from mail.xzibition.com (localhost [172.31.3.2]) by mail.xzibition.com (Postfix) with ESMTP id 6FB968CCD; Wed, 9 Aug 2017 19:46:50 +0000 (UTC) X-Virus-Scanned: amavisd-new at mail.xzibition.com Received: from mail.xzibition.com ([172.31.3.2]) by mail.xzibition.com (mail.xzibition.com [172.31.3.2]) (amavisd-new, port 10026) with LMTP id ieDzQPuxbJAM; Wed, 9 Aug 2017 19:46:43 +0000 (UTC) Subject: Re: [bmake] bmake sigint handling causing tty corruption DKIM-Filter: OpenDKIM Filter v2.9.2 mail.xzibition.com 257C88CC8 To: "Simon J. Gerraty" , Konstantin Belousov Cc: Dmitry Marakasov , freebsd-current@FreeBSD.org References: <20170718205700.GA2131@hades.panopticon> <20170720112904.GH1935@kib.kiev.ua> <6076.1500572036@kaos.jnpr.net> From: Bryan Drewery Openpgp: id=F9173CB2C3AAEA7A5C8A1F0935D771BB6E4697CF; url=http://www.shatow.net/bryan/bryan2.asc Organization: FreeBSD Message-ID: <36a12e36-6217-a9aa-0199-2e1119c5eec8@FreeBSD.org> Date: Wed, 9 Aug 2017 12:46:42 -0700 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: <6076.1500572036@kaos.jnpr.net> Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="aBMn8xglig55uiqPp4VfmVbvlCjRRlnvQ" X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.23 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: Wed, 09 Aug 2017 19:46:52 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --aBMn8xglig55uiqPp4VfmVbvlCjRRlnvQ Content-Type: multipart/mixed; boundary="Ida0f4dSppp93FKEUHsqEf9fUqUDS5SHa"; protected-headers="v1" From: Bryan Drewery To: "Simon J. Gerraty" , Konstantin Belousov Cc: Dmitry Marakasov , freebsd-current@FreeBSD.org Message-ID: <36a12e36-6217-a9aa-0199-2e1119c5eec8@FreeBSD.org> Subject: Re: [bmake] bmake sigint handling causing tty corruption References: <20170718205700.GA2131@hades.panopticon> <20170720112904.GH1935@kib.kiev.ua> <6076.1500572036@kaos.jnpr.net> In-Reply-To: <6076.1500572036@kaos.jnpr.net> --Ida0f4dSppp93FKEUHsqEf9fUqUDS5SHa Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: quoted-printable On 7/20/2017 10:33 AM, Simon J. Gerraty wrote: > Konstantin Belousov wrote: >> I just find is somewhat strange that make initiates a new session. >=20 > In jobs mode it does - to ensure the child and all progeny can be kille= d > in one fell swoop. > In compat mode it does not, but that does not mean the child cannot do > so. >=20 >> Did you verified that enabling the wait code in make(1) fixes the issu= e ? >=20 > FWIW it is a reasonably simple patch to make to wait for child to exit > before self termination. >=20 There's a similar bug with compat vs jobs mode in that stdout/stderr actually being a TTY is not conveyed to the jobs children. Gmake conveys both stdout and stderr as TTY to children [1]. This causes clang's color diagnostics to not be enabled by default with jobs mode since it is looking at stderr for being a TTY. It works fine in compat mode. I've been working around it with this to avoid the detection: > /etc/make.conf:CFLAGS.clang+=3D -fcolor-diagnostics Ccache also wanted to pass this flag along if stderr was a TTY, which meant that jobs mode and compat mode ended up using different caches since one had the flag and the other did not. I fixed the ccache port to not hashing the flag entirely though in ports r408673 / 2016-02. I had written this patch to "fix" bmake a few years ago, https://people.freebsd.org/~bdrewery/patches/bmake-job-stderr-tty.patch. However I took another look at the problem last year and came up with an entirely different patch. I think the problem with my naive patch there is that stderr/stdin are actually passed through the same pipe for jobs mode, so my second attempt was to create a separate stderr pipe similar to the existing job.outPipe, rather than the naive patch just sending stderr to the real one. I ran into more issues with that though with interspersed messages IIRC. I abandoned the work for that. [1] bmake vs gmake: > # cat Makefile > blah: > @if [ -t 0 ]; then echo "0 is a TTY"; fi > @if [ -t 1 ]; then echo "1 is a TTY"; fi > @if [ -t 2 ]; then echo "2 is a TTY"; fi > # make > Building /usr/obj/root/git/freebsd/tmp/blah > 0 is a TTY > # make -j2 > Building /usr/obj/root/git/freebsd/tmp/blah > # gmake > 0 is a TTY > 1 is a TTY > 2 is a TTY > # gmake -j2 > 0 is a TTY > 1 is a TTY > 2 is a TTY > # --=20 Regards, Bryan Drewery --Ida0f4dSppp93FKEUHsqEf9fUqUDS5SHa-- --aBMn8xglig55uiqPp4VfmVbvlCjRRlnvQ Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQEcBAEBAgAGBQJZi2aiAAoJEDXXcbtuRpfP9jEH/3YA1BIYp5coApT7wpuIISfT VAL7IHoXYS95HO6pTMypMuiHMOJW1EuTLmuEicG+JHWdfA3xjr0yK0u29bkseJ4i c/fMlag9fUU6+XsyYN+Pz/dyzo1Lb50A9APEWtr4XyDA2k6BjkQuf6nyazB7jm4q pMN71X7k8UnFQ0hBWaJbs+8f0Sg4O+biN+GvPuafssXW2EjeAkdQD+aYRcnXMMr+ TkADVdJkoJQPFxlsZJ9XOi227iEqsn1wSLJ+HDElbtgvsMTYiRxN203IKxwm/k/f OSkb1UKRQ1tj6bcKkLNrEbaDsUcINUJCnuMoAHC9VQZWCqsifBZRQU97uZvjXZI= =wDXk -----END PGP SIGNATURE----- --aBMn8xglig55uiqPp4VfmVbvlCjRRlnvQ--