[PATCH] D95230: Save and restore previous terminal after setting the terminal for checking if terminal supports colors.

Pavel Labath via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 11 01:47:20 PST 2021


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG075de2d8a756: Save and restore previous terminal after setting the terminal for checking if… (authored by augusto2112, committed by labath).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D95230/new/

https://reviews.llvm.org/D95230

Files:
  llvm/lib/Support/Unix/Process.inc


Index: llvm/lib/Support/Unix/Process.inc
===================================================================
--- llvm/lib/Support/Unix/Process.inc
+++ llvm/lib/Support/Unix/Process.inc
@@ -336,6 +336,7 @@
   // First, acquire a global lock because these C routines are thread hostile.
   std::lock_guard<std::mutex> G(*TermColorMutex);
 
+  struct term *previous_term = set_curterm(nullptr);
   int errret = 0;
   if (setupterm(nullptr, fd, &errret) != 0)
     // Regardless of why, if we can't get terminfo, we shouldn't try to print
@@ -359,7 +360,7 @@
 
   // Now extract the structure allocated by setupterm and free its memory
   // through a really silly dance.
-  struct term *termp = set_curterm(nullptr);
+  struct term *termp = set_curterm(previous_term);
   (void)del_curterm(termp); // Drop any errors here.
 
   // Return true if we found a color capabilities for the current terminal.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D95230.329881.patch
Type: text/x-patch
Size: 899 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210311/0a60037b/attachment.bin>


More information about the llvm-commits mailing list