Avoid running more than one DIAL request at a time (b/12017240)
The S99miniclient script must have finished executing before
a second DIAL request is executed in order to avoid having
multiple instances running at once.
Change-Id: I3132d734ef1fbab0a809dfb42f455ee58630af49
diff --git a/src/server/main.c b/src/server/main.c
index 0d8a7fc..57bc0eb 100644
--- a/src/server/main.c
+++ b/src/server/main.c
@@ -219,6 +219,10 @@
exit(1);
} else {
*run_id = (void *)(long)pid; // parent PID
+ // Wait until the script S99miniclient is done before continuing
+ waitpid(pid, NULL, 0);
+ // TODO(jfthibert) Should we try to wait a few seconds until the actual
+ // program is started?
}
return kDIALStatusRunning;
} else {
@@ -320,8 +324,6 @@
DIAL_run_t run_id, int* pCanStop, void *callback_data) {
// Netflix application can stop
*pCanStop = 1;
-
- waitpid((pid_t)run_id, NULL, WNOHANG); // reap child
return isAppRunning( spAppNetflix, NULL ) ? kDIALStatusRunning : kDIALStatusStopped;
}
@@ -333,7 +335,6 @@
{
fprintf(stderr, "Killing pid %d\n", pid);
kill((pid_t)pid, SIGTERM);
- waitpid((pid_t)pid, NULL, 0); // reap child
}
}