Re: [bmake] bmake sigint handling causing tty corruption

From: Bryan Drewery <bdrewery_at_FreeBSD.org>
Date: Wed, 9 Aug 2017 12:46:42 -0700
On 7/20/2017 10:33 AM, Simon J. Gerraty wrote:
> Konstantin Belousov <kostikbel_at_gmail.com> wrote:
>> I just find is somewhat strange that make initiates a new session.
> 
> In jobs mode it does - to ensure the child and all progeny can be killed
> in one fell swoop.
> In compat mode it does not, but that does not mean the child cannot do
> so.
> 
>> Did you verified that enabling the wait code in make(1) fixes the issue ?
> 
> FWIW it is a reasonably simple patch to make to wait for child to exit
> before self termination.
> 

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+=   -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:
>         _at_if [ -t 0 ]; then echo "0 is a TTY"; fi
>         _at_if [ -t 1 ]; then echo "1 is a TTY"; fi
>         _at_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
> #


-- 
Regards,
Bryan Drewery


Received on Wed Aug 09 2017 - 17:46:52 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:41:12 UTC