mirror of
https://github.com/tio/tio.git
synced 2026-05-01 14:57:59 +02:00
Quit from non-interactive mode using ctrl-c
When piping to tio it will automatically enter "non-interactive" mode which means it will not react to any input key sequences but simple read the input stream and write it to the tty device. This also means that ctrl-t q can not be used to quit and so tio would hang forever when used in non-interactive mode. This change allows to send the standard termination signal by pressing ctrl-c on tio in non-interactive mode to make it quit.
This commit is contained in:
parent
eadcc7e384
commit
5f46136b28
3 changed files with 77 additions and 45 deletions
|
|
@ -27,15 +27,24 @@
|
|||
#include "error.h"
|
||||
#include "print.h"
|
||||
#include "misc.h"
|
||||
#include "tty.h"
|
||||
|
||||
static void signal_handler(int signum)
|
||||
{
|
||||
UNUSED(signum);
|
||||
tio_printf("Received hangup signal!");
|
||||
switch (signum)
|
||||
{
|
||||
case SIGHUP:
|
||||
tio_printf("Received SIGHUP signal!");
|
||||
break;
|
||||
case SIGINT:
|
||||
tio_printf("Received SIGINT signal!");
|
||||
break;
|
||||
}
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
void signal_handlers_install(void)
|
||||
{
|
||||
signal(SIGHUP, signal_handler);
|
||||
signal(SIGINT, signal_handler);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue