mirror of
https://codeberg.org/FabricSoul/dwl.git
synced 2025-08-03 20:10:23 -04:00
set O_NONBLOCK flag to stdout
This commit is contained in:
parent
2b4893a0ad
commit
71f11e6cf6
3 changed files with 23 additions and 0 deletions
16
util.c
16
util.c
|
@ -3,6 +3,7 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#include "util.h"
|
||||
|
||||
|
@ -33,3 +34,18 @@ ecalloc(size_t nmemb, size_t size)
|
|||
die("calloc:");
|
||||
return p;
|
||||
}
|
||||
|
||||
int
|
||||
fd_set_nonblock(int fd) {
|
||||
int flags = fcntl(fd, F_GETFL);
|
||||
if (flags < 0) {
|
||||
perror("fcntl(F_GETFL):");
|
||||
return -1;
|
||||
}
|
||||
if (fcntl(fd, F_SETFL, flags | O_NONBLOCK) < 0) {
|
||||
perror("fcntl(F_SETFL):");
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue