]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
irqtop: fix open file descriptor leak
authorSami Kerola <kerolasa@iki.fi>
Sat, 4 Jan 2020 09:35:19 +0000 (09:35 +0000)
committerSami Kerola <kerolasa@iki.fi>
Fri, 21 Feb 2020 21:09:14 +0000 (21:09 +0000)
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 <kerolasa@iki.fi>
sys-utils/irqtop.c

index b4f0cc11129e5b851b37c02a5905139630b63b9c..c9f8faf9ceff3510c445387c81fb24ee94fbeaaa 100644 (file)
@@ -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;
 }