On Mon, Jan 9, 2012 at 4:58 PM, Natanael Copa <[email protected]> wrote:
>>> I wonder what the proper way to handle this is. Probably do some
>>> netlink stuff to detect new devices for acpid?
>>
>> Another solution is just to restart acpid.
>> Best to do it automatically from hotplug helper...
>
> That'd be a simpler solution yes, and more than good enough.
>
>>> Quick workaround would be to just close fd on POLLHUP or POLLERR:
>>
>>> diff --git a/util-linux/acpid.c b/util-linux/acpid.c
>>> index 6e7321b..3d723c0 100644
>>> --- a/util-linux/acpid.c
>>> +++ b/util-linux/acpid.c
>>> @@ -292,6 +292,11 @@ int acpid_main(int argc UNUSED_PARAM, char **argv)
>>>                 for (i = 0; i < nfd; i++) {
>>>                         const char *event = NULL;
>>>
>>> +                       if (pfd[i].revents & (POLLERR | POLLHUP)) {
>>> +                               close(pfd[i].fd);
>>> +                               pfd[i].fd = -1;
>>> +                       }
>>> +
>>
>> I'm a bit surprised this would work: I don't remember any special case
>> in poll() to ignore fds < 0, so it _might_ start returning POLLNVAL
>> on this pfd[i] from now on.
>
> From http://pubs.opengroup.org/onlinepubs/009695399/functions/poll.html:
>
> "If the value of fd is less than 0, events shall be ignored, and
> revents shall be set to 0 in that entry on return from poll()."

Good to know.

>> With your fix, what happens when you power your screen back on?
>
> CPU goes back to normal and everything seems to work as it did ...
>
>> I guess the keyboard and mouse ACPI events are no longer detected by acpid,
>> right?
>
> ... except for the keyboard and mouse. I havent really checked but
> yes, I assume it stops to detect mouse and keyboard events since those
> fd's are closed and never reopened.
>
> fork/exec'ing itself again would solve that.

Well, not really, because we do not know WHEN to re-exec.
We don't know when new devices appear.

> Do you have other applets
> that re-start themselves? I could send a new patch - including a
> comment with a reference for the ignore fd == -1 thingy. Or should we
> just exit the acpid and let a hook script restart it?

I think a good solution is when hotplug machinery does something like
"sv t /var/service/acpid" whenever a new input device appears.

-- 
vda
_______________________________________________
busybox mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/busybox

Reply via email to