read-dev-usbmon: retry ioctl when interrupted

Allows read-dev-usbmon to function after suspend/resume.
This commit is contained in:
Peter Wu
2013-04-27 21:33:19 +02:00
parent af94dbf89b
commit bfcf1487ae

View File

@@ -26,6 +26,7 @@
#include <string.h>
#include <stdint.h>
#include <stdlib.h> /* getenv */
#include <errno.h>
typedef uint16_t u16;
typedef int32_t s32;
@@ -104,6 +105,9 @@ int main(int argc, char ** argv) {
for (;;) {
memset(&data, 0xCC, sizeof data); // for debugging purposes
r = ioctl(fd, MON_IOCX_GET, &event);
if (r == -1 && errno == EINTR) {
continue;
}
if (r < 0) {
perror("ioctl");
break;