signal(SIGHUP, SIG_DFL);
signal(SIGUSR1, SIG_IGN);
+ /* we need a blocking fd here as recv() might return EAGAIN otherwise. */
+ ret = mark_fd_blocking(fd);
+ if (ret < 0)
+ goto err_out;
challenge_nr = random();
/* send Welcome message */
ret = send_va_buffer(fd, "This is para_server, version "
return ret;
}
+/**
+ * Set a file descriptor to blocking mode.
+ *
+ * \param fd The file descriptor.
+ *
+ * \return Standard.
+ */
+int mark_fd_blocking(int fd)
+{
+ int flags = fcntl(fd, F_GETFL);
+ if (flags < 0)
+ return -ERRNO_TO_PARA_ERROR(errno);
+ flags = fcntl(fd, F_SETFL, ((long)flags) & ~O_NONBLOCK);
+ if (flags < 0)
+ return -ERRNO_TO_PARA_ERROR(errno);
+ return 1;
+}
+
/**
* Set a file descriptor to non-blocking mode.
*
int para_select(int n, fd_set *readfds, fd_set *writefds,
struct timeval *timeout_tv);
int mark_fd_nonblock(int fd);
+int mark_fd_blocking(int fd);
void para_fd_set(int fd, fd_set *fds, int *max_fileno);
__must_check int para_fgets(char *line, int size, FILE *f);
void *para_mmap(size_t length, int prot, int flags, int fd, off_t offset);