diff --git a/xdg/keypressdetector/evdev.c b/xdg/keypressdetector/evdev.c index cc3f956..e440a87 100644 --- a/xdg/keypressdetector/evdev.c +++ b/xdg/keypressdetector/evdev.c @@ -1,10 +1,11 @@ +#include #include "evdev.h" int block_until_keypress(const char* keyboardPath) { int keyboardFd = open(keyboardPath, O_RDONLY); if (keyboardFd < 0) { - return keyboardFd; + return errno; } int eventSize = sizeof(struct input_event); @@ -15,7 +16,7 @@ int block_until_keypress(const char* keyboardPath) { while(readEvents) { bytesRead = read(keyboardFd, events, eventSize * NUM_EVENTS); if (bytesRead < 0) { - return bytesRead; + return errno; } for(int i = 0; i < (bytesRead / eventSize); ++i) { diff --git a/xdg/keypressdetector/evdev.go b/xdg/keypressdetector/evdev.go index 56f94ef..e4a443c 100644 --- a/xdg/keypressdetector/evdev.go +++ b/xdg/keypressdetector/evdev.go @@ -20,7 +20,7 @@ func (Evdev) BlockUntilKeypress(devicePath string) error { defer C.free(unsafe.Pointer(path)) ret := C.block_until_keypress(path) - if ret < 0 { + if ret != 0 { return syscall.Errno(ret) }