[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Make does not clean up the target when stderr is piped. Why?

From: Masahiro Yamada
Subject: Re: Make does not clean up the target when stderr is piped. Why?
Date: Thu, 10 Jun 2021 12:27:55 +0900

Hi Kaz,

On Sat, Jun 5, 2021 at 11:41 PM Kaz Kylheku (gmake)
<> wrote:
> On 2021-06-05 07:00, Masahiro Yamada wrote:
> >   make 2>&1 | tee build.log
> >
> > is a very common use case, and people often
> > miss to add  (trap "" 2; ...), I think.
> Hi Masahiro,
> tee has a -i option to ignore the SIGINT signal.
> This is even specified by POSIX!
> Might that help in this specific scenario?
> (If tee ignores the SIGINT signal, how does it then terminate?
> make will quit first, and then tee reacts to the EOF on its standard
> input.)

I did not know this option.

It is true that this option is very useful,
but a problem is that not all people in the Linux kernel
community know the GNU Make internal
or tee having -i option.

I was considering two options.

[1] Add documentation and ask users to ensure that
     when stderr of make is piped to another command,
     that command should not die. Use -i option for 'tee'

[2] Modify Makefiles to do cleanups (for example by using 'trap')
     without relying on Make.

Maybe I want to try [2] because
not all users read the documentation.

Anyway, thank you for the useful input!

> If that helps, consider that the filename arguments in tee are optional;
> tee copies stdin to stdout while duplicating the stream to
> *zero* or more files.
> Thus:
>     make | tee -i | grep ....
> Whoever added this -i option might have intended it
> for exactly this scenario: as a pipe element that protects the
> previous element from SIGPIPE.
> The Coreutils tee's documentation says that -i ignores interrupt
> signals (suggesting more than one) but strace reveals only
> this:
>    rt_sigaction(SIGINT, {sa_handler=SIG_IGN, sa_mask=[INT],
> sa_flags=SA_RESTART}, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) =
> 0

Best Regards
Masahiro Yamada

reply via email to

[Prev in Thread] Current Thread [Next in Thread]