@@ -736,8 +736,13 @@ int xcrunToolCommand(std::vector<std::string> commandAndArguments, XcrunToolBloc
736736 dup2 (outPipe[1 ], STDOUT_FILENO);
737737 dup2 (errPipe[1 ], STDERR_FILENO);
738738
739+ close (outPipe[0 ]);
740+ close (errPipe[0 ]);
741+
739742 execv (launchPath, (char *const *)arguments.data ());
740743 }
744+ close (outPipe[1 ]);
745+ close (errPipe[1 ]);
741746
742747 // Read stdout and stderr in parallel, then wait for the task
743748 // to exit. Anything else risks deadlock if the task fills
@@ -754,9 +759,11 @@ int xcrunToolCommand(std::vector<std::string> commandAndArguments, XcrunToolBloc
754759 });
755760
756761 auto const stdOutData = readToEOF (outPipe[0 ]);
762+ close (outPipe[0 ]);
757763
758764 dispatch_semaphore_wait (gotStdErr, DISPATCH_TIME_FOREVER);
759765 dispatch_release (gotStdErr);
766+ close (errPipe[0 ]);
760767
761768 int status = 0 ;
762769 waitpid (childPid, &status, 0 );
@@ -881,6 +888,7 @@ void enumerateDirectory(std::string directory, F&& func) {
881888 return ;
882889 }
883890
891+ std::vector<std::string> subpaths;
884892 struct dirent *entry;
885893 while ((entry = readdir (dir)) != NULL ) {
886894 std::string path = directory + " /" + entry->d_name ;
@@ -891,9 +899,13 @@ void enumerateDirectory(std::string directory, F&& func) {
891899 if (strncmp (entry->d_name , " .." , entry->d_namlen ) == 0 ) {
892900 continue ;
893901 }
894- enumerateDirectory (path, func );
902+ subpaths. push_back (path);
895903 }
896904 }
905+ closedir (dir);
906+ for (auto const &path : subpaths) {
907+ enumerateDirectory (path, func);
908+ }
897909}
898910
899911
0 commit comments