bug-diffutils
[Top][All Lists]
Advanced

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

[bug-diffutils] bug#20062: bug#20062: bug#20062: [PATCH] diff: add suppo


From: Giuseppe Scrivano
Subject: [bug-diffutils] bug#20062: bug#20062: bug#20062: [PATCH] diff: add support for --color
Date: Fri, 13 Mar 2015 11:57:11 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux)

Paul Eggert <address@hidden> writes:

> We can't use 'fileno' or 'error' inside a signal handler; they're not
> async-signal-safe.  And we can't use 'outfile', as it's not volatile.
>
> Instead, I suggest redoing begin_output so that 'outfile' is always
> stdout and its file descriptor is 1; that way, 'write' can use
> STDOUT_FILENO instead of fileno (stdout).  (You can use dup2 to
> arrange for this after the pipe calls.) Do not call 'error'; just
> return and let the signal handler re-raise the signal and exit.

we can do it right now I think, as anyway we use signals only when we
are outputting to a terminal so it doesn't cover the pipe case.

> Also, what happens if a signal occurs when 'diff' is outputting an
> escape sequence?  E.g., suppose 'diff' is in the middle of outputting
> "\x1B[31m" and gets interrupted after the '[', so that it outputs
> "\x1B[\x1b[0m".  Is this guaranteed to reset the terminal?  If not,
> what sequence of bytes is guaranteed to reset the terminal color even
> if the sequence is output immediately after a truncated escape
> sequence?

I could not find any immediate answer, neither in the ncurses, but on
the terminals I have tried it is enough to reset even in the middle of
another sequence.  We could play safe and output it twice, but IMHO it
doesn't seem to be needed.

I'll send an updated version later today.

Thanks,
Giuseppe





reply via email to

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