13
3
I often pipe program output to less, e.g.
produce_output | less
This works great, until produce_output
produces large amounts of output. If I search for some text that is deep into the file, less reports
Calculating line numbers... (interrupt to abort)
If I interrupt with Control+C, it also kills produce_output
, which stops it from producing further output. Is there any way to send the interrupt to less, so that produce_output
keeps running?
I know that I could use kill -INT less_process
, but I think there must be a better solution.
It light of the problem raised by OP it seems that decision to use CTRL+C as a way to interrupt less is very unfortunate. Do you know why this specific signal was chosen? Would some other signal be less problematic? – Piotr Dobrogost – 2015-01-21T11:21:27.980
@PiotrDobrogost: What other signal would you suggest? There aren't many that have dedicated keyboard shortcuts, only SIGINT (Ctrl-C) and SIGQUIT (Ctrl-\), and the latter is meant to exit the program immediately, not merely interrupt. The rest are only available via
kill
. – user1686 – 2015-01-21T11:28:47.003It seems that the problem is caused by using signal to interrupt less. Instead, if it were some normal key/shortcut we wouldn't have the problem in the first place. However I guess the need for a signal comes from the fact that process can't use
select
to wait for input both from a file/pipe and terminal at the same time. – Piotr Dobrogost – 2015-01-21T12:49:04.010@PiotrDobrogost: It can, that's how the
F
(follow) mode works. Pipes and ttys are pollable the same way. – user1686 – 2015-01-21T13:10:16.930Why do you think that's the way follow mode works? I think the flow of events is that shell gets CTRL+C and sends SIGINT signal to less which gets this signal asynchronously without listening to keyboard/terminal. – Piotr Dobrogost – 2015-01-21T15:58:21.020