select.c: Introduce support for signalfd

The signalfd(2) mechanism of Linux allows signals to be delivered
and processed via normal file descriptor I/O.  This avoids any of the
usual problems about re-entrancy of signal processing, as signals can
be processed from the osmocom select() loop abstraction just like any
other event.

Change-Id: If8d89dd1f6989e1cd9b9367fad954d65f91ada30
diff --git a/include/osmocom/core/select.h b/include/osmocom/core/select.h
index 92904e2..bc60198 100644
--- a/include/osmocom/core/select.h
+++ b/include/osmocom/core/select.h
@@ -7,6 +7,7 @@
 #include <osmocom/core/linuxlist.h>
 #include <stdbool.h>
 #include <time.h>
+#include <signal.h>
 
 /*! \defgroup select Select loop abstraction
  *  @{
@@ -68,4 +69,21 @@
 			  const struct timespec *interval);
 int osmo_timerfd_setup(struct osmo_fd *ofd, int (*cb)(struct osmo_fd *, unsigned int), void *data);
 
+/* signalfd integration */
+struct osmo_signalfd;
+struct signalfd_siginfo;
+
+typedef void osmo_signalfd_cb(struct osmo_signalfd *osfd, const struct signalfd_siginfo *fdsi);
+
+struct osmo_signalfd {
+	struct osmo_fd ofd;
+	sigset_t sigset;
+	osmo_signalfd_cb *cb;
+	void *data;
+};
+
+struct osmo_signalfd *
+osmo_signalfd_setup(void *ctx, sigset_t set, osmo_signalfd_cb *cb, void *data);
+
+
 /*! @} */