mirror of
https://github.com/ksherlock/TwoTerm.git
synced 2024-06-10 04:29:33 +00:00
in high sierra, estimated read size always seems to be 0. handle that situation.
This commit is contained in:
parent
de8810b8e2
commit
a6408fc242
|
@ -236,7 +236,7 @@
|
||||||
|
|
||||||
static uint8_t sbuffer[1024];
|
static uint8_t sbuffer[1024];
|
||||||
size_t estimated = dispatch_source_get_data(_read_source);
|
size_t estimated = dispatch_source_get_data(_read_source);
|
||||||
|
estimated = std::max(estimated, sizeof(sbuffer));
|
||||||
|
|
||||||
uint8_t *buffer = estimated > sizeof(sbuffer) ? (uint8_t *)malloc(estimated) : sbuffer;
|
uint8_t *buffer = estimated > sizeof(sbuffer) ? (uint8_t *)malloc(estimated) : sbuffer;
|
||||||
if (buffer)
|
if (buffer)
|
||||||
|
@ -244,7 +244,7 @@
|
||||||
ssize_t actual;
|
ssize_t actual;
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
actual = read(fd, buffer, (estimated));
|
actual = read(fd, buffer, estimated);
|
||||||
if (actual < 0) {
|
if (actual < 0) {
|
||||||
if (errno == EINTR) continue;
|
if (errno == EINTR) continue;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user