diff --git a/linux/hid.c b/linux/hid.c
index 56dac0f..f99cd5c 100644
--- a/linux/hid.c
+++ b/linux/hid.c
@@ -629,7 +629,7 @@ hid_device * HID_API_EXPORT hid_open_path(const char *path)
dev->device_handle = open(path, O_RDWR);
/* If we have a good handle, return it. */
- if (dev->device_handle > 0) {
+ if (dev->device_handle >= 0) {
/* Get the report descriptor */
int res, desc_size = 0;
Playing with usbrelay (which uses hidapi), I noticed that it fails if FD 0 is closed and that an open result is FD 0 being allocated by the kernel:
strace confirms this:
The bug seems to be here: https://github.com/signal11/hidapi/blob/98629a104b9f567e6cfde263febc3bc776970b50/linux/hid.c#L632
easily fixed with: