From 09f6a74c899277fc288ced9ba2a3b89db686f87a Mon Sep 17 00:00:00 2001 From: e2dk4r <43293320+e2dk4r@users.noreply.github.com> Date: Sat, 19 Oct 2024 19:39:51 +0300 Subject: [PATCH] src: fix crash after when system sleep After Suspend-to-RAM, io_uring wait returns error EINTR. Test with below command $ echo mem > /sys/power/state see: https://www.kernel.org/doc/html/v4.18/admin-guide/pm/sleep-states.html --- src/main.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main.c b/src/main.c index 07e03da..2b0015d 100644 --- a/src/main.c +++ b/src/main.c @@ -420,9 +420,13 @@ main(void) wait: error = io_uring_wait_cqe(&ring, &cqe); if (error) { - if (errno == EAGAIN) + error *= -1; + if (error == EAGAIN || error == EINTR) goto wait; fatal("io_uring\n"); +#if GAMEPAD_IDLE_INHIBIT_DEBUG + printf("errno: %d %s\n", -error, strerror(-error)); +#endif error_code = GAMEPAD_ERROR_IO_URING_WAIT; break; }