Fix: write/read expect number of bytes, not len

This commit is contained in:
Nikita Ivanov 2022-06-05 00:31:16 +05:00
parent 302c77245b
commit 09e688d53b
No known key found for this signature in database
GPG Key ID: 6E656AC5B97B5133
2 changed files with 2 additions and 2 deletions

View File

@ -132,7 +132,7 @@ static int run(Preview *p, int *exitcode)
if (*exitcode != FAILED_PREVIEW_EC) {
char buf[256];
int len;
while ((len = read(pipe_fds[0], buf, LEN(buf))) > 0) {
while ((len = read(pipe_fds[0], buf, sizeof(buf))) > 0) {
write(STDOUT_FILENO, buf, len);
}

View File

@ -90,7 +90,7 @@ static int listen(char *fifo)
if (pollfd.revents & POLLIN) {
static char buf[1024];
while ((len = read(pollfd.fd, buf, LEN(buf))) > 0) {
while ((len = read(pollfd.fd, buf, sizeof(buf))) > 0) {
/* But first byte equal to 0 means "exit" */
if (buf[0] == 0)
goto close;