Add fix for O_NONBLOCK file-descriptor as output pipe

If the output of an fd is a pipe with O_NONBLOCK set, the script will die as
soon as the pipe fills up due to the write call returning with EAGAIN. This
fixes that.

Signed-off-by: Tyrolyean <tyrolyean@tyrolyean.net>
This commit is contained in:
Tyrolyean 2022-07-17 20:03:32 +02:00
parent 4123b78a81
commit be8f7d1716
No known key found for this signature in database
GPG key ID: 81EC9BAC5E9667C6

View file

@ -51,7 +51,7 @@ static int write_retry(int fd, const void *buffer, size_t size)
int ret = write(fd, buffer, size); int ret = write(fd, buffer, size);
if (ret < 0) { if (ret < 0) {
if (errno == EINTR) if (errno == EINTR || errno == EAGAIN)
continue; continue;
perror("write"); perror("write");
return -1; return -1;