Convert _wait_for_command (in server.utils) to use Popen.poll instead
of os.waitpid. We already use Popen objects which means that
terminated processes may have already been reaped without our
knowledge. The Popen.poll method can handle this case, but a raw
waitpid call cannot.

Signed-off-by: John Admanski <jadmanski@google.com>



git-svn-id: http://test.kernel.org/svn/autotest/trunk@1302 592f7852-d20e-0410-864c-8624ca9c26a4
diff --git a/server/utils.py b/server/utils.py
index 3c673b1..3756544 100644
--- a/server/utils.py
+++ b/server/utils.py
@@ -208,16 +208,16 @@
 			_process_output(subproc.stderr, stderr_file,
 					stderr_tee)
 
-		pid, exit_status_indication = os.waitpid(subproc.pid,
-							 os.WNOHANG)
-		if pid:
+		exit_status_indication = subproc.poll()
+
+		if exit_status_indication is not None:
 			return exit_status_indication
 		if timeout:
 			time_left = stop_time - time.time()
 
 	# the process has not terminated within timeout,
 	# kill it via an escalating series of signals.
-	if not pid:
+	if exit_status_indication is None:
 		__nuke_subprocess(subproc)
 	raise AutoservRunError('Command not complete within %s seconds'
 			       % timeout, None)