From cef97539b2928e72eb7b87bd9d187e07d89d01fb Mon Sep 17 00:00:00 2001 From: dtfinch Date: Sun, 16 Mar 2014 11:57:43 -0700 Subject: [PATCH] Reduce cpu usage Before, it would max out a cpu core at 100% while waiting (undesirable if what it's waiting on needs the full cpu). Adding a 1ms sleep reduced its usage to about 1% in my case. --- src/waitpid.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/src/waitpid.cc b/src/waitpid.cc index 6cc76e3..0123749 100644 --- a/src/waitpid.cc +++ b/src/waitpid.cc @@ -16,6 +16,7 @@ static Handle Waitpid(const Arguments& args) { child = args[0]->Int32Value(); do { + usleep(1000); r = waitpid(child, &status, WNOHANG); } while (r != -1);