[PATCH] D27239: [sanitizer] Make atos stdin a non-tty pipe to make sure it's not stuck waiting for user input

Filipe Cabecinhas via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 2 09:50:37 PST 2016


filcab added a comment.

LGTM



================
Comment at: lib/sanitizer_common/sanitizer_symbolizer_posix_libcdep.cc:114
+  int sock_pair[5][2];
+  for (int i = 0; i < 5; i++) {
+    if (pipe(sock_pair[i]) == -1) {
----------------
Maybe extract the `5` to be a constant?
Also, why `5`? It looks to me that 4 should be enough (I was planning on 3, which would make a bigger difference, but then noticed you want two pairs):
worst case: 0, 1, and 2 are closed.
`pipe()` creates 0, 1 <- Not good, keep trying
`pipe()` creates 2, X <- Not good, keep trying
`pipe()` creates Y, X <- ok, since 0, 1, and 2 are already taken by previous pipes.
`pipe()` creates A, B <- ok


================
Comment at: lib/sanitizer_common/sanitizer_symbolizer_posix_libcdep.cc:189
+      close(STDIN_FILENO);
+      CHECK_GE(dup2(infd[0], STDIN_FILENO), 0);
+      close(infd[0]);
----------------
`dup2` will close `STDIN_FILENO` by itself. No need to close it first.


Repository:
  rL LLVM

https://reviews.llvm.org/D27239





More information about the llvm-commits mailing list