1
0
mirror of https://github.com/irssi/irssi.git synced 2024-12-04 14:46:39 -05:00

Quit if terminal gets lost.

git-svn-id: http://svn.irssi.org/repos/irssi/trunk@1960 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
Timo Sirainen 2001-11-03 13:12:15 +00:00 committed by cras
parent 06435bea22
commit ab99ca7231
2 changed files with 15 additions and 1 deletions

View File

@ -331,6 +331,12 @@ void readline(void)
int ret, i; int ret, i;
ret = term_gets(buffer, sizeof(buffer)); ret = term_gets(buffer, sizeof(buffer));
if (ret == -1) {
/* lost terminal */
signal_emit("command quit", 1, "Lost terminal");
return;
}
for (i = 0; i < ret; i++) for (i = 0; i < ret; i++)
handle_key(buffer[i]); handle_key(buffer[i]);
} }

View File

@ -328,6 +328,14 @@ void term_stop(void)
int term_gets(unsigned char *buffer, int size) int term_gets(unsigned char *buffer, int size)
{ {
int ret;
/* fread() doesn't work */ /* fread() doesn't work */
return read(fileno(current_term->in), buffer, size); ret = read(fileno(current_term->in), buffer, size);
if (ret == 0)
ret = -1;/* EOF - terminal got lost */
else if (ret == -1 && (errno == EINTR || errno == EAGAIN))
ret = 0;
return ret;
} }