[PATCH] acpid: close filehandles for unplugged input devices

Natanael Copa natanael.copa at gmail.com
Fri Jan 6 14:01:39 UTC 2012


acpid will hang in an endless loop if we unplug an input device,
for example USB mouse or keyboard after acpid has started.

To work around this we simply close the handle.

Signed-off-by: Natanael Copa <ncopa at alpinelinux.org>
---
 util-linux/acpid.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/util-linux/acpid.c b/util-linux/acpid.c
index 6e7321b..39c58f2 100644
--- a/util-linux/acpid.c
+++ b/util-linux/acpid.c
@@ -294,6 +294,11 @@ int acpid_main(int argc UNUSED_PARAM, char **argv)
 
 			memset(&ev, 0, sizeof(ev));
 
+			if (pfd[i].revents & (POLLERR | POLLHUP)) {
+				close(pfd[i].fd);
+				pfd[i].fd = -1;
+			}
+
 			if (!(pfd[i].revents & POLLIN))
 				continue;
 
-- 
1.7.8.2



More information about the busybox mailing list