Merge "Fix deadlocks."
diff --git a/adb/framebuffer_service.c b/adb/framebuffer_service.c
index 8cbe840..61578aa 100644
--- a/adb/framebuffer_service.c
+++ b/adb/framebuffer_service.c
@@ -76,6 +76,7 @@
         exit(1);
     }
 
+    close(fds[1]);
     fd_screencap = fds[0];
 
     /* read w, h & format */
@@ -173,10 +174,9 @@
     }
 
 done:
-    TEMP_FAILURE_RETRY(waitpid(pid, NULL, 0));
-
     close(fds[0]);
-    close(fds[1]);
+
+    TEMP_FAILURE_RETRY(waitpid(pid, NULL, 0));
 pipefail:
     close(fd);
 }