libutil: read window size from stdout if stderr fails

This fixes the output of `nix help 2>/dev/null` so it stops wrapping at
60 columns.

Change-Id: Id0000000842b5befd73afbd6aff2825bdeae46af
This commit is contained in:
Lily Ballard
2025-05-17 12:19:06 -07:00
parent 18aebab9b6
commit 8630cedbca
+1 -1
View File
@@ -106,7 +106,7 @@ static Sync<std::pair<unsigned short, unsigned short>> windowSize{{0, 0}};
void updateWindowSize()
{
struct winsize ws;
if (ioctl(2, TIOCGWINSZ, &ws) == 0) {
if (ioctl(2, TIOCGWINSZ, &ws) == 0 || ioctl(1, TIOCGWINSZ, &ws) == 0) {
auto windowSize_(windowSize.lock());
windowSize_->first = ws.ws_row;
windowSize_->second = ws.ws_col;