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.
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);
}