Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
if (!r) common_diee("malloc");
return r;
}
+
+void nonblock(int fd) {
+ int r;
+ r= fcntl(fd,F_GETFL); if (r<0) common_diee("nonblock fcntl F_GETFL");
+ r |= O_NONBLOCK;
+ r= fcntl(fd,F_SETFL,r); if (r<0) common_diee("nonblock fcntl F_GETFL");
+}
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
+#include <fcntl.h>
char *m_vasprintf(const char *fmt, va_list al);
char *m_asprintf(const char *fmt, ...);
/* to be provided by program: */
void common_die(const char *what);
void common_diee(const char *what); /* prints errno */
+void nonblock(int fd);
void *xmalloc(size_t sz);
#include <endian.h>
#include <sys/types.h>
-#include <fcntl.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include "myopt.h"
+#include "common.h"
typedef unsigned char Byte;
/*---------- general stuff ----------*/
-static void nonblock(int fd) {
- int r;
- r= fcntl(fd,F_GETFL); if (r<0) sysfail("nonblock fcntl F_GETFL");
- r |= O_NONBLOCK;
- r= fcntl(fd,F_SETFL,r); if (r<0) sysfail("nonblock fcntl F_GETFL");
-}
-
static void blocksignals(int how) {
sigset_t set;
int r;