From bc90c16a789b01b71c1bd02aba5da2183fa36d1b Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Sat, 4 Jan 2020 09:35:19 +0000 Subject: [PATCH] irqtop: fix open file descriptor leak With very short delay one can see irqfile file descriptors pile up rather quickly causing program to stop with too many open files error. This commit fixes that, and removes couple other memory leaks. With these the command should hopefully run fine for days if not even months. Signed-off-by: Sami Kerola --- sys-utils/irqtop.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/sys-utils/irqtop.c b/sys-utils/irqtop.c index b4f0cc1112..c9f8faf9ce 100644 --- a/sys-utils/irqtop.c +++ b/sys-utils/irqtop.c @@ -175,7 +175,8 @@ static struct irq_stat *get_irqinfo(struct irqtop_ctl *ctl) sizeof(*stat->irq_info) * stat->nr_irq_info); } } - + fclose(irqfile); + free(buffer); return stat; close_file: @@ -462,8 +463,9 @@ int main(int argc, char *argv[]) if (is_tty) tcsetattr(STDIN_FILENO, TCSAFLUSH, &saved_tty); - if (!ctl.run_once) + if (ctl.win) { + delwin(ctl.win); endwin(); - + } return retval; } -- 2.47.2