Switch init to epoll.
Not just because it's what the cool kids are doing --- it also lets us
simplify the inner loop and decouple it from whatever systems want to
be woken to perform some activity if there's data to be read on some fd.
Currently this is just used to clean up the existing signal handling,
keychord, and property service code.
Change-Id: I4d7541a2c4386957ad877df69e3be08b96a7dec5
diff --git a/init/signal_handler.cpp b/init/signal_handler.cpp
index 37d21bc..39a466d 100644
--- a/init/signal_handler.cpp
+++ b/init/signal_handler.cpp
@@ -147,7 +147,7 @@
}
}
-void handle_signal() {
+static void handle_signal() {
// Clear outstanding requests.
char buf[32];
read(signal_read_fd, buf, sizeof(buf));
@@ -161,7 +161,7 @@
}
}
-void signal_init() {
+void signal_handler_init() {
// Create a signalling mechanism for SIGCHLD.
int s[2];
if (socketpair(AF_UNIX, SOCK_STREAM | SOCK_NONBLOCK | SOCK_CLOEXEC, 0, s) == -1) {
@@ -180,8 +180,6 @@
sigaction(SIGCHLD, &act, 0);
reap_any_outstanding_children();
-}
-int get_signal_fd() {
- return signal_read_fd;
+ register_epoll_handler(signal_read_fd, handle_signal);
}