From 0b9e1fa170796ee96db7cc831f76a7bc056eb0cc Mon Sep 17 00:00:00 2001 From: xorrvin Date: Mon, 15 Jun 2026 20:11:15 +0200 Subject: [PATCH] Use nanosleep --- cage.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cage.c b/cage.c index 8eee709..42121bf 100644 --- a/cage.c +++ b/cage.c @@ -201,12 +201,15 @@ cleanup_primary_client(pid_t pid) wlr_log(WLR_DEBUG, "Sending SIGTERM to child with pid %d", pid); kill(pid, SIGTERM); + /* 100 ms in nanoseconds */ + struct timespec ts = {0, 100000000}; + /* 10 sec timeout with 100ms intervals */ for(int i = 0; i < 100; i++) { if(waitpid(pid, &status, WNOHANG) > 0) { goto done; } - usleep(100000); + nanosleep(&ts, NULL); } wlr_log(WLR_INFO, "Child did not exit after 10s, sending SIGKILL");