Fixed constant re-opening kernel pipe.

This commit is contained in:
2019-09-04 17:15:21 +01:00
parent aeb9c89be8
commit 80b552012d

View File

@@ -32,12 +32,11 @@ void closeHTML(FILE* fPtr);
#endif #endif
shared_ptr<int> getHostDescriptor() { shared_ptr<int> getHostDescriptor() {
static shared_ptr<int> descriptor{}; static shared_ptr<int> descriptor{ new int{ open(HID_DEV, O_RDWR | O_NONBLOCK | O_APPEND) },
[](int* fd) {
descriptor.reset(new int{ open(HID_DEV, O_RDWR | O_NONBLOCK | O_APPEND) }, [](int* fd) { close(*fd);
close(*fd); delete fd;
delete fd; } };
});
if (*descriptor == -1) if (*descriptor == -1)
throw runtime_error{ "Descriptor is unavailable" }; throw runtime_error{ "Descriptor is unavailable" };