diff --git a/src/rfkill.c b/src/rfkill.c index a0a50d9e45d94887645640729ad0d76741c347c5..f2a2eea436cd3f856b67b566c22539fcad5b68b0 100644 --- a/src/rfkill.c +++ b/src/rfkill.c @@ -93,14 +93,18 @@ int rfkill_get_blocked(uint16_t index) return -1; } + fcntl(fd, F_SETFL, O_NONBLOCK); // 设置非阻塞模式 + while (1) { struct rfkill_event event = { 0 }; int id; ssize_t len; len = read(fd, &event, sizeof(event)); - if (len < RFKILL_EVENT_SIZE_V1) + if (len < 0) { + info("Failed to read rfkill event, index %u: %s", index, strerror(errno)); break; + } id = get_adapter_id_for_rfkill(event.idx);