]> granicus.if.org Git - psmisc/commitdiff
pstree: fclose fopened files
authorCraig Small <csmall@enc.com.au>
Sun, 2 Feb 2014 06:02:36 +0000 (17:02 +1100)
committerCraig Small <csmall@enc.com.au>
Sun, 2 Feb 2014 06:02:36 +0000 (17:02 +1100)
Commit [9de89a] uses fopen to find the tasks, but doesn't fclose
them afterward. Thanks for the anonymous and somewhat obscure
bug commenter for pointing it out.

Signed-off-by: Craig Small <csmall@enc.com.au>
src/pstree.c

index 1cbe13124cc1d4868723e16a5de28a3fec16e394..071e6c4d6b384e64eac35f7d4c408db1ead886ba 100644 (file)
@@ -2,7 +2,7 @@
  * pstree.c - display process tree
  *
  * Copyright (C) 1993-2002 Werner Almesberger
- * Copyright (C) 2002-2012 Craig Small
+ * Copyright (C) 2002-2014 Craig Small
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -812,12 +812,14 @@ static char* get_threadname(const pid_t pid, const int tid, const char *comm)
                ++thread_comm;
                *endcomm = '\0';
                sprintf(threadname, "{%.*s}", COMM_LEN, thread_comm);
+               (void) fclose(file);
                return threadname;
            }
        }
     }
     /* Fall back to old method */
     sprintf(threadname, "{%.*s}", COMM_LEN, comm);
+    fclose(file);
     return threadname;
 }