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
22
shadermeh.c
22
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,10 +52,23 @@ 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;
|
||||||
perror("write");
|
}else if(errno == EAGAIN){
|
||||||
return -1;
|
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)
|
if (ret == 0)
|
||||||
|
|
Loading…
Reference in a new issue