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:
parent
51f808d12f
commit
47bbca6806
1 changed files with 18 additions and 4 deletions
22
shadermeh.c
22
shadermeh.c
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue