mirror of
https://github.com/ksherlock/TwoTerm.git
synced 2025-08-16 00:27:41 +00:00
in high sierra, estimated read size always seems to be 0. handle that situation.
This commit is contained in:
@@ -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;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user