}
/*---------------------------------------------------------------*/
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)
/* 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);
/* 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);
acpid_log(LOG_ERR, "input layer read error: %s (%d)\n",
strerror(errno), errno);
if (++nerrs >= ACPID_MAX_ERRS) {