Skip to content

Commit bea2d7d

Browse files
committed
Exit with code 1 if an error occurs while reading from the input device
1 parent fc1db8a commit bea2d7d

File tree

4 files changed

+8
-6
lines changed

4 files changed

+8
-6
lines changed

configure.ac

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Process this file with autoconf to produce a configure script.
33

44
AC_PREREQ([2.69])
5-
AC_INIT([linux-touch-gestures], [1.0.3], [[email protected]])
5+
AC_INIT([linux-touch-gestures], [1.0.4], [[email protected]])
66
AM_INIT_AUTOMAKE
77
AC_CONFIG_SRCDIR([src/main.c])
88

src/gesture_detection.c

+3-2
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,7 @@ static void *scroll_thread_function(void *val) {
460460
return NULL;
461461
}
462462

463-
void process_events(int fd, configuration_t config, void (*callback)(input_event_array_t*)) {
463+
int process_events(int fd, configuration_t config, void (*callback)(input_event_array_t*)) {
464464
struct input_event ev[64];
465465
int i, rd;
466466

@@ -487,7 +487,7 @@ void process_events(int fd, configuration_t config, void (*callback)(input_event
487487

488488
if (rd < (int) sizeof(struct input_event)) {
489489
printf("expected %d bytes, got %d\n", (int) sizeof(struct input_event), rd);
490-
return;
490+
return 1;
491491
}
492492

493493
for (i = 0; i < rd / sizeof(struct input_event); i++) {
@@ -529,4 +529,5 @@ void process_events(int fd, configuration_t config, void (*callback)(input_event
529529
}
530530
}
531531
}
532+
return 0;
532533
}

src/gesture_detection.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,6 @@
2828
#include "configuraion.h"
2929
#include "input_event_array.h"
3030

31-
void process_events(int fd, configuration_t config, void (*callback)(input_event_array_t*));
31+
int process_events(int fd, configuration_t config, void (*callback)(input_event_array_t*));
3232

3333
#endif // GESTURE_DETECTION_H_

src/main.c

+3-2
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ static int open_touch_device(configuration_t config, int retry) {
146146
}
147147

148148
int main(int argc, char *argv[]) {
149+
int exit_code = 0;
149150
if (argc > 1) {
150151
configuration_t config = read_config(argv[1]);
151152
int_array_t *keys = get_keys_array(config);
@@ -166,10 +167,10 @@ int main(int argc, char *argv[]) {
166167
}
167168
printf("Opened input device\n");
168169
fflush(stdout);
169-
process_events(touch_device_fd, config, &execute_events);
170+
exit_code = process_events(touch_device_fd, config, &execute_events);
170171

171172
close(touch_device_fd);
172173
destroy_uinput(uinput_fd);
173174
}
174-
return 0;
175+
return exit_code;
175176
}

0 commit comments

Comments
 (0)