diff -ur old/acpid-1.0.10-netlink4/connection_list.c new/acpid-1.0.10-netlink4/connection_list.c --- old/acpid-1.0.10-netlink4/connection_list.c 2009-07-20 06:35:40.000000000 +0400 +++ new/acpid-1.0.10-netlink4/connection_list.c 2009-10-07 22:46:22.000000000 +0400 @@ -73,6 +73,26 @@ } /*---------------------------------------------------------------*/ +void delete_connection(int fd) +{ + int i; + + close(fd); + + /* remove from the fd set */ + FD_CLR(fd, &allfds); + + for (i = 0; i < nconnections; ++i) { + /* if the file descriptors match, delete the connection */ + if (connection_list[i].fd == fd) { + --nconnections; + connection_list[i] = connection_list[nconnections]; + break; + } + } +} + +/*---------------------------------------------------------------*/ struct connection * find_connection(int fd) diff -ur old/acpid-1.0.10-netlink4/connection_list.h new/acpid-1.0.10-netlink4/connection_list.h --- old/acpid-1.0.10-netlink4/connection_list.h 2009-04-29 18:37:13.000000000 +0400 +++ new/acpid-1.0.10-netlink4/connection_list.h 2009-10-07 21:59:35.000000000 +0400 @@ -41,6 +41,9 @@ /* add a connection to the list */ extern void add_connection(struct connection *p); +/* delete a connection from the list */ +extern void delete_connection(int fd); + /* find a connection in the list by file descriptor */ extern struct connection *find_connection(int fd); diff -ur old/acpid-1.0.10-netlink4/input_layer.c new/acpid-1.0.10-netlink4/input_layer.c --- old/acpid-1.0.10-netlink4/input_layer.c 2009-07-20 02:31:49.000000000 +0400 +++ new/acpid-1.0.10-netlink4/input_layer.c 2009-10-07 21:58:00.000000000 +0400 @@ -133,7 +133,11 @@ /* if it's a signal, bail */ if (errno == EINTR) return; - + if (errno == ENODEV) { + acpid_log(LOG_WARNING, "input device has been disconnected\n"); + delete_connection(fd); + return; + } acpid_log(LOG_ERR, "input layer read error: %s (%d)\n", strerror(errno), errno); if (++nerrs >= ACPID_MAX_ERRS) {