'slabtop -o' with stdin not a tty would complain
When the command is executed in one shot mode (-o) with stdin being something other than a terminal, the tcgetattr() call would fail, and generate an error message. e.g.: slabtop: terminal setting retrieval: Inappropriate ioctl for device Active / Total Objects (% used) : 905319 / 915886 (98.8%) Signed-off-by: Craig Small <csmall@enc.com.au>
This commit is contained in:
parent
7610b3128e
commit
96c524990b
@ -286,7 +286,7 @@ static void parse_input(char c)
|
|||||||
#define print_line(fmt, ...) if (run_once) printf(fmt, __VA_ARGS__); else printw(fmt, __VA_ARGS__)
|
#define print_line(fmt, ...) if (run_once) printf(fmt, __VA_ARGS__); else printw(fmt, __VA_ARGS__)
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
int o;
|
int is_tty, o;
|
||||||
unsigned short old_rows;
|
unsigned short old_rows;
|
||||||
struct slab_info *slab_list = NULL;
|
struct slab_info *slab_list = NULL;
|
||||||
int run_once = 0, retval = EXIT_SUCCESS;
|
int run_once = 0, retval = EXIT_SUCCESS;
|
||||||
@ -337,7 +337,8 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tcgetattr(STDIN_FILENO, &saved_tty) == -1)
|
is_tty = isatty(STDIN_FILENO);
|
||||||
|
if (is_tty && tcgetattr(STDIN_FILENO, &saved_tty) == -1)
|
||||||
xwarn(_("terminal setting retrieval"));
|
xwarn(_("terminal setting retrieval"));
|
||||||
|
|
||||||
old_rows = rows;
|
old_rows = rows;
|
||||||
@ -429,6 +430,7 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
} while (delay);
|
} while (delay);
|
||||||
|
|
||||||
|
if (is_tty)
|
||||||
tcsetattr(STDIN_FILENO, TCSAFLUSH, &saved_tty);
|
tcsetattr(STDIN_FILENO, TCSAFLUSH, &saved_tty);
|
||||||
free_slabinfo(slab_list);
|
free_slabinfo(slab_list);
|
||||||
if (!run_once)
|
if (!run_once)
|
||||||
|
Loading…
Reference in New Issue
Block a user