From 5ebdf3a92f55c582f7b23236b4b403faa76f1f19 Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Sun, 6 Jun 2010 18:32:11 +0200 Subject: [PATCH 1/1] gui: Avoid busy loop if audiod is down. The old approach to sleep one second is not sufficient and might still lead to a busy loop as the call to sleep() might be interrupted by SIGCHILD. So check the return value of sleep() and sleep again if it is not zero. --- gui.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/gui.c b/gui.c index fc2cd9a1..01cca6e6 100644 --- a/gui.c +++ b/gui.c @@ -880,7 +880,13 @@ static int open_audiod_pipe(void) if (init) init = 0; else - sleep(1); + /* + * Sleep a bit to avoid a busy loop. As the call to sleep() may + * be interrupted by SIGCHLD, we simply wait until the call + * succeeds. + */ + while (sleep(2)) + ; /* nothing */ return para_open_audiod_pipe(conf.stat_cmd_arg); } -- 2.30.2