libreadline is not exiting on Ctrl+C from paginated "__more__" output state (possible completions on tab)

28 Views Asked by At

My application uses libreadline to auto complete timezone strings (on pressing tab) for timezone command.
As there are lot of possible completions the output is paginated with __more__.
In this state if I press q it exits fine but if I press Ctrl+C the behavior is as shown below.. (it wont exit until all the entries in the buffer printed out, but printing junk).

$ timezone <tab>
Display all 200 possibilities? (y or n) y    
Africa/Maputo                   America/Moncton                 Asia/Kuwait                     Europe/Stockholm
Africa/Maseru                   America/Monterrey               Asia/Macau                      Europe/Tallinn
Africa/Mbabane                  America/Montevideo              Asia/Magadan                    Europe/Tirane
Africa/Mogadishu                America/Montreal                Asia/Makassar                   Europe/Uzhgorod
Africa/Monrovia                 America/Montserrat              Asia/Manila                     Europe/Vaduz
--More--^C
�"^TxU                         ^P�"^TxU                        ��"^TxU                         ��"^TxU
^P^?"^TxU                       ^P�"^TxU                        ��"^TxU                         ��"^TxU
0�"^TxU                         ^P�"^TxU                        ��"^TxU                         ��"^TxU
0�"^TxU                         ^P�"^TxU                        ��"^TxU                         ��"^TxU
0�"^TxU                         ^P�"^TxU                        ��"^TxU                         ��"^TxU
0�"^TxU                         ��"^TxU                         ��"^TxU                         ^P�"^TxU
0�"^TxU                         ��"^TxU                         ��"^TxU                         @�"^TxU

By the way my SIGINT handler function is as below, and I am using rl_attempted_completion_function to register my own function to provide possible completion strings char**.

rl_initialize();
printf("\n");
rl_forced_update_display();

How to make Ctrl+C to behave exactly as pressing q on pagination?.

0

There are 0 best solutions below