forked from goliath/shadermeh
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
16
shadermeh.c
16
shadermeh.c
|
@ -5,6 +5,7 @@
|
||||||
* Copyright (C) 2022 David Oberhollenzer <goliath@infraroot.at>
|
* Copyright (C) 2022 David Oberhollenzer <goliath@infraroot.at>
|
||||||
*/
|
*/
|
||||||
#include "shadermeh.h"
|
#include "shadermeh.h"
|
||||||
|
#include <fcntl.h>
|
||||||
|
|
||||||
static GLfloat vertex_buffer[] = {
|
static GLfloat vertex_buffer[] = {
|
||||||
-1.0f, -1.0f, 0.0f, /* lower left corner */
|
-1.0f, -1.0f, 0.0f, /* lower left corner */
|
||||||
|
@ -51,9 +52,22 @@ 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){
|
||||||
continue;
|
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");
|
perror("write");
|
||||||
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue