Page MenuHomePhabricator

Don't break curses applications in terminalHasColors()
Needs ReviewPublic

Authored by osandov on Aug 12 2016, 11:00 AM.

Details

Reviewers
chandlerc
Summary

terminalHasColors() reinitializes curses every time it is called,
which breaks curses applications. For example, bcc was seeing Python
curses crashes in https://github.com/iovisor/bcc/pull/615, and GNU
readline is broken by llvm::SMDiagnostic::print() in my own project:
https://github.com/osandov/asmase/issues/1.

Instead of reinitializing curses every time we check for colors, only do
it if curses hasn't already been initialized. For that, we can check
cur_term, the global variable which is set up by curses when
newterm() or setupterm() is called.

Event Timeline

osandov updated this revision to Diff 67863.Aug 12 2016, 11:00 AM
osandov retitled this revision from to Don't break curses applications in terminalHasColors().
osandov updated this object.
osandov added a reviewer: chandlerc.
ast added a subscriber: ast.Aug 12 2016, 5:43 PM
osandov updated this object.Aug 12 2016, 5:53 PM
osandov updated this revision to Diff 78439.Nov 17 2016, 4:59 PM
osandov updated this object.

Rebase. @chandlerc, could you please take a look?