Control: retitle -1 less: with -R, escape sequences are not sent to the 
terminal in an atomic way, yielding a race condition

On 2017-07-20 13:18:34 +0200, Vincent Lefevre wrote:
> [...]
> +Two-output division (10.5.5)
> +mulRevToPair
> [32m+Boolean functions of intervals (10.5.10)
> +less
> +precedes
> [...]
> 
> The "[32m" shouldn't be there, and the color of this line is
> incorrect as a consequence (the escape sequence was not interpreted
> as such). On 10 tests, the problem occurred 7 times.

I've eventually found the cause of the problem. Thanks to xterm
logging, I could see that at about the same time this line was sent to
the terminal, an escape sequence was also sent to update the title of
the terminal, and there was a clash between the two escape sequences.

The update of the title of the terminal is done by my shell settings
via a TRAPCHLD(). More precisely, when running "scd ... | m", I get:

  │   └─> 1594  zsh
  │     ├─> 19375  zsh
  │     │ └─> 19378  perl tdiff
  │     └─> 19376  less

and when I type [End] in "less", tdiff terminates (it was blocking
due to a full output buffer, I assume), and I get:

  │   └─> 1594  zsh
  │     └─> 19376  less

The termination of process 19375 yields a SIGCHLD, trapped by the
interactive shell (1594), which updates the title of the terminal.

In the xterm logs, I can see:
1. ESC from "less";
2. the escape sequence from zsh (to update the title of the terminal);
3. the end of the escape sequence from "less": "[32m".

So, it seems that the issue is that "less" with the -R option does not
send the escape sequence in an atomic way.

-- 
Vincent Lefèvre <vinc...@vinc17.net> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)

Reply via email to