Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 9 Aug 2017 12:46:42 -0700
From:      Bryan Drewery <bdrewery@FreeBSD.org>
To:        "Simon J. Gerraty" <sjg@juniper.net>, Konstantin Belousov <kostikbel@gmail.com>
Cc:        Dmitry Marakasov <amdmi3@amdmi3.ru>, freebsd-current@FreeBSD.org
Subject:   Re: [bmake] bmake sigint handling causing tty corruption
Message-ID:  <36a12e36-6217-a9aa-0199-2e1119c5eec8@FreeBSD.org>
In-Reply-To: <6076.1500572036@kaos.jnpr.net>
References:  <20170718205700.GA2131@hades.panopticon> <20170720112904.GH1935@kib.kiev.ua> <6076.1500572036@kaos.jnpr.net>

next in thread | previous in thread | raw e-mail | index | archive | help
This is an OpenPGP/MIME signed message (RFC 4880 and 3156)
--aBMn8xglig55uiqPp4VfmVbvlCjRRlnvQ
Content-Type: multipart/mixed; boundary="Ida0f4dSppp93FKEUHsqEf9fUqUDS5SHa";
 protected-headers="v1"
From: Bryan Drewery <bdrewery@FreeBSD.org>
To: "Simon J. Gerraty" <sjg@juniper.net>,
 Konstantin Belousov <kostikbel@gmail.com>
Cc: Dmitry Marakasov <amdmi3@amdmi3.ru>, 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 <kostikbel@gmail.com> 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--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?36a12e36-6217-a9aa-0199-2e1119c5eec8>