Page MenuHomePhabricator

Properly cache terminal width and dirty on SIGWINCH
ClosedPublic

Authored by epriestley on Oct 2 2017, 7:01 PM.
Tags
None
Referenced Files
F19320402: D18669.diff
Dec 25 2025, 8:54 AM
F19289091: D18669.id44824.diff
Dec 23 2025, 7:54 AM
F18820525: D18669.id44824.diff
Oct 22 2025, 3:40 PM
F18756432: D18669.diff
Oct 5 2025, 11:25 AM
F18681325: D18669.diff
Sep 26 2025, 4:23 AM
F18677483: D18669.id44825.diff
Sep 25 2025, 9:07 PM
F17948025: D18669.id.diff
Jul 31 2025, 7:53 PM
F17941329: D18669.diff
Jul 31 2025, 5:18 AM
Subscribers
None

Details

Summary

See PHI110. Currently, the cache here is bad: if tput fails, we'll keep running tput over and over again, since null is not cached.

Instead:

  • Cache null.
  • Dirty the cache when we receivew SIGWINCH, which indicates the window/terminal metadata has changed.
Test Plan
  • Ran scripts/test/progress_bar.php in wide and narrow windows, saw it fit to the window.
  • Resized the window while it was running, saw it (mostly) figure it out (it can leave some artifacts behind, but we can't do much about that).
  • Added some debugging "print" statements to make sure the cache was working, saw it only recalculate once and then after a resize.

Diff Detail

Repository
rPHU libphutil
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

amckinley added inline comments.
src/console/format.php
217–218

Maybe keep this comment? I was briefly confused by this too.

This revision is now accepted and ready to land.Oct 2 2017, 7:51 PM
src/console/format.php
217–218

Oh, sure -- I originally thought I could write this in a slightly less dumb way and make what was going on a little more obvious, but PhutilExecPassthru doesn't currently have a mode to pass some kind of normal pipe for stdout/stderr.

This revision was automatically updated to reflect the committed changes.