mirror of
https://github.com/upa/mscp.git
synced 2026-02-04 03:24:58 +08:00
Fix: fallback to default terminal size on no tty
This commit is contained in:
@@ -697,8 +697,13 @@ void print_progress_bar(double percent, char *suffix)
|
||||
|
||||
buf[0] = '\0';
|
||||
|
||||
if (ioctl(STDOUT_FILENO, TIOCGWINSZ, &ws) < 0)
|
||||
return; /* XXX */
|
||||
if (ioctl(STDOUT_FILENO, TIOCGWINSZ, &ws) < 0 || ws.ws_col == 0) {
|
||||
|
||||
// fallback to default
|
||||
ws.ws_col = 80;
|
||||
ws.ws_row = 24;
|
||||
}
|
||||
|
||||
bar_width = min(sizeof(buf), ws.ws_col) - strlen(suffix) - 7;
|
||||
|
||||
memset(buf, 0, sizeof(buf));
|
||||
|
||||
Reference in New Issue
Block a user