mirror of
https://github.com/upa/mscp.git
synced 2026-02-16 19:04:44 +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';
|
buf[0] = '\0';
|
||||||
|
|
||||||
if (ioctl(STDOUT_FILENO, TIOCGWINSZ, &ws) < 0)
|
if (ioctl(STDOUT_FILENO, TIOCGWINSZ, &ws) < 0 || ws.ws_col == 0) {
|
||||||
return; /* XXX */
|
|
||||||
|
// fallback to default
|
||||||
|
ws.ws_col = 80;
|
||||||
|
ws.ws_row = 24;
|
||||||
|
}
|
||||||
|
|
||||||
bar_width = min(sizeof(buf), ws.ws_col) - strlen(suffix) - 7;
|
bar_width = min(sizeof(buf), ws.ws_col) - strlen(suffix) - 7;
|
||||||
|
|
||||||
memset(buf, 0, sizeof(buf));
|
memset(buf, 0, sizeof(buf));
|
||||||
|
|||||||
Reference in New Issue
Block a user