From: Sami Kerola Date: Sat, 4 Jan 2020 09:35:19 +0000 (+0000) Subject: irqtop: fix open file descriptor leak X-Git-Tag: v2.36-rc1~196^2~41 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=bc90c16a789b01b71c1bd02aba5da2183fa36d1b;p=thirdparty%2Futil-linux.git 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 --- 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; }