Fixed constant re-opening kernel pipe.
This commit is contained in:
11
Streams.cpp
11
Streams.cpp
@@ -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" };
|
||||||
|
|||||||
Reference in New Issue
Block a user