#ifdef BSD
# include <paths.h>
#endif
+#include <poll.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
return 0;
}
+int
+fd_hasdata(int fd)
+{
+ struct pollfd fds;
+ int retval;
+
+ if (fd == -1)
+ return -1;
+ fds.fd = fd;
+ fds.events = POLLIN;
+ fds.revents = 0;
+ retval = poll(&fds, 1, 0);
+ if (retval == -1)
+ return -1;
+ if (retval > 0 && fds.revents & POLLIN)
+ return retval;
+ return 0;
+}
+
int
close_on_exec(int fd)
{
#include <stdio.h>
#include <string.h>
+#define UNCONST(a) ((void *)(unsigned long)(const void *)(a))
+
#if __GNUC__ > 2 || defined(__INTEL_COMPILER)
# define _unused __attribute__((__unused__))
#else
int close_fds(void);
int close_on_exec(int);
+int fd_hasdata(int);
ssize_t get_line(char **, size_t *, FILE *);
int get_time(struct timeval *);
time_t uptime(void);