tycat/tyls: handle error on write()/scanf()

This commit is contained in:
Boris Faure 2020-04-05 15:49:26 +02:00
parent 58a1adac38
commit a119ac10cc
Signed by untrusted user who does not match committer: borisfaure
GPG Key ID: 35C0410516166BE8
2 changed files with 12 additions and 4 deletions

View File

@ -337,7 +337,11 @@ main(int argc, char **argv)
echo_off();
snprintf(buf, sizeof(buf), "%c}qs", 0x1b);
if (ty_write(1, buf, strlen(buf) + 1) < 0)
perror("write");
{
perror("write");
echo_on();
goto shutdown;
}
if (scanf("%i;%i;%i;%i", &tw, &th, &cw, &ch) != 4 ||
((tw <= 0) || (th <= 0) || (cw <= 1) || (ch <= 1)))
{

View File

@ -760,18 +760,22 @@ main(int argc, char **argv)
int i, cw, ch;
int len;
char *rp;
evas = ecore_evas_get(ee);
echo_off();
snprintf(buf, sizeof(buf), "%c}qs", 0x1b);
len = strlen(buf);
if (ty_write(1, buf, len + 1) < (signed)len + 1)
perror("write");
{
perror("write");
echo_on();
return -1;
}
if ((scanf("%i;%i;%i;%i", &tw, &th, &cw, &ch) != 4)
|| (tw <= 0) || (th <= 0) || (cw <= 1) || (ch <= 1))
{
echo_on();
return 0;
return -1;
}
echo_on();
for (i = 1; i < argc; i++)