Subject: bug#20062: [bug-diffutils] bug#20062: bug#20062: bug#20062: [PATCH] diff: add support for --color

From: Paul Eggert <[email-masked]>
Date: Fri, 11 Sep 2015 08:28:04 -0700

Gisle Vanem wrote:
> No. He added a 'reset_color_context (true);' inside
> 'signal_handler()'.

Ah, sorry, I was looking at the original edition of the patch.

I just now looked at <http://bugs.gnu.org/20062#101> and still see some 
problems.  Mainly, it doesn't handle SIGTSTP properly.  With SIGTSTP an 
application is supposed to reset the terminal and then resignal itself with 
SIGSTOP before really stopping.  When restarting the application then needs to 
restore the terminal to the current state, if the current state is not the 
default.  This is nearly impossible to do correctly with the proposed design.  I 
suggest looking at how GNU ls does it: the signal handler merely sets a flag, 
and the application checks occasionally at safe places whether a signal has arrived.

A nit: when installing signals via 'signal', don't install a handler if 'signal' 
says the signal is being ignored.

Also, copyright papers need to be filed for diffutils before a nontrivial patch 
like this can be installed.