On Mon, 29 Jun 2020 18:49:33 GMT, John Neffenger <github.com+1413266+jgn...@openjdk.org> wrote:
>> The rationale makes sense (open/open/close) instead of (open/close/open) > > Based on my notes below, I believe this change is safe for any Linux input > device driver because the driver shouldn't > receive the intermediate *open* and *close* calls at all. > Nonetheless, it would be reassuring if someone could try [this > change](https://github.com/openjdk/jfx/pull/258/files) > just once on a mainstream device, such as the Raspberry Pi with a touchscreen > LCD panel. I only have six obscure ARM > devices and a headless QEMU ARM virtual machine for testing. @johanvos or > @dellgreen - Is that something you could > test? If you think it's overkill and not worth it, that's fine, too. #### > Notes > The Linux kernel documentation about [opening and > closing](https://www.kernel.org/doc/html/latest/input/input-programming.html#dev-open-and-dev-close) > input devices > states: >> Note that input core keeps track of number of users for the device and makes >> sure that dev->open() is called only when >> the first user connects to the device and that dev->close() is called when >> the very last user disconnects. Calls to >> both callbacks are serialized. > > Also, the Linux Programmer's Manual for the *close* system call (`man 2 > close`) states: > >> If *fd* is the last file descriptor referring to the underlying open file >> description (see **open**(2)), the resources >> associated with the open file description are freed. > > Running a JavaFX program with `strace -f -e trace=open,close -o strace.log` > shows the one *open* for the *event0* > keyboard, and the *open, open, close* for the *event1* touchscreen: > 5847 open("/dev/input/event0", O_RDONLY) = 11 > ... > 5847 open("/dev/input/event1", O_RDONLY) = 12 > 5847 open("/dev/input/event1", O_RDONLY) = 13 > 5847 close(13) = 0 > > Both devices are actually closed by the kernel when the JavaFX program ends. I don't have access to a Pi right now, so I can't test this (I'll be able to test in about 10 days from now though) ------------- PR: https://git.openjdk.java.net/jfx/pull/258