Is there any way to exit “less” follow mode without stopping other processes in pipe?

Works OK for me when looking at a file that's being appended to but not when input comes from a pipe (using the F command - control-C works fine then).

See discussion at Follow a pipe using less? - this is a known bug/shortcoming in less.


Is there any way to exit “less” follow mode without ^C?

Yes, starting from version 569 one can exit follow mode with CTRL+X which does not stop other processes in a pipe.

For earlier versions of less (supporting only CTRL+C) one can arrange things so that SIGINT signal which is being sent when pressing CTRL+C does not effect other processes in a pipe thus allowing them to continue running. This can be achieved by doing any of the following:

  • preventing SIGINT from reaching other processes in a pipe by moving these processes into a separate process group using setsid utility:

(setsid seq 10000000) | less +F

  • handling (catching) SIGINT so that it does not get delivered to other processes in a pipe:

(trap '' INT; seq 10000000) | less +F

  • using process substitution (non POSIX feature, implemented in Bash, Zsh and Ksh but not in e.g. Dash):

less -f +F <(seq 10000000)

  • sending processes to the background (using the fact that shells ignore SIGINT and SIGQUIT in backgrounded processes):

(seq 10000000 &) | less +F

To observe effects of above commands on process groups and signal handling I suggest using ps -O ppid,pgrp,sid,ignored --forest -C bash,less,seq command in a separate terminal.