26 lines
401 B
C
26 lines
401 B
C
|
|
||
|
#include "utils.h"
|
||
|
|
||
|
#include <stdio.h>
|
||
|
#include <stdlib.h>
|
||
|
|
||
|
void fatal(const gchar* msg) {
|
||
|
fprintf(stderr, "%s\n", msg);
|
||
|
abort();
|
||
|
}
|
||
|
|
||
|
void fd_init(int fd) {
|
||
|
#ifdef _WIN32
|
||
|
int i = 1;
|
||
|
#endif
|
||
|
#ifdef FD_CLOEXEC
|
||
|
/* close fd on exec (cgi) */
|
||
|
fcntl(fd, F_SETFD, FD_CLOEXEC);
|
||
|
#endif
|
||
|
#ifdef O_NONBLOCK
|
||
|
fcntl(fd, F_SETFL, O_NONBLOCK | O_RDWR);
|
||
|
#elif defined _WIN32
|
||
|
ioctlsocket(fd, FIONBIO, &i);
|
||
|
#endif
|
||
|
}
|