diff options
| -rw-r--r-- | st.c | 25 |
1 files changed, 16 insertions, 9 deletions
| @@ -823,17 +823,24 @@ ttyread(void) | |||
| 823 | int ret; | 823 | int ret; |
| 824 | 824 | ||
| 825 | /* append read bytes to unprocessed bytes */ | 825 | /* append read bytes to unprocessed bytes */ |
| 826 | if ((ret = read(cmdfd, buf+buflen, LEN(buf)-buflen)) < 0) | 826 | ret = read(cmdfd, buf+buflen, LEN(buf)-buflen); |
| 827 | die("couldn't read from shell: %s\n", strerror(errno)); | ||
| 828 | buflen += ret; | ||
| 829 | 827 | ||
| 830 | written = twrite(buf, buflen, 0); | 828 | switch (ret) { |
| 831 | buflen -= written; | 829 | case 0: |
| 832 | /* keep any uncomplete utf8 char for the next call */ | 830 | fputs("Found EOF in input\n", stderr); |
| 833 | if (buflen > 0) | 831 | exit(0); |
| 834 | memmove(buf, buf + written, buflen); | 832 | case -1: |
| 833 | die("couldn't read from shell: %s\n", strerror(errno)); | ||
| 834 | default: | ||
| 835 | buflen += ret; | ||
| 836 | written = twrite(buf, buflen, 0); | ||
| 837 | buflen -= written; | ||
| 838 | /* keep any uncomplete utf8 char for the next call */ | ||
| 839 | if (buflen > 0) | ||
| 840 | memmove(buf, buf + written, buflen); | ||
| 841 | return ret; | ||
| 835 | 842 | ||
| 836 | return ret; | 843 | } |
| 837 | } | 844 | } |
| 838 | 845 | ||
| 839 | void | 846 | void |
