Add fix for output being O_NONBLOCK

This tries to remove the O_NONBLOCK flag from an output FD if the output seems
to be setup this way.

Signed-off-by: Tyrolyean <tyrolyean@tyrolyean.net>
This commit is contained in:
Tyrolyean 2022-07-18 00:06:34 +02:00
parent 51f808d12f
commit 47bbca6806
No known key found for this signature in database
GPG key ID: 81EC9BAC5E9667C6

View file

@ -5,6 +5,7 @@
* Copyright (C) 2022 David Oberhollenzer <goliath@infraroot.at>
*/
#include "shadermeh.h"
#include <fcntl.h>
static GLfloat vertex_buffer[] = {
-1.0f, -1.0f, 0.0f, /* lower left corner */
@ -51,10 +52,23 @@ static int write_retry(int fd, const void *buffer, size_t size)
int ret = write(fd, buffer, size);
if (ret < 0) {
if (errno == EINTR)
continue;
perror("write");
return -1;
if (errno == EINTR){
continue;
}else if(errno == EAGAIN){
perror("Output pipe probably has O_NONBLOCK "
"set! Removing setting");
ret = fcntl(STDOUT_FILENO, F_SETFL,
fcntl(STDOUT_FILENO,F_GETFL)
&(~O_NONBLOCK));
if(ret == -1){
perror("Failed to set STDOUT blocking");
return -1;
}
continue;
}else{
perror("write");
}
return -1;
}
if (ret == 0)