diff options
-rw-r--r-- | procps/top.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/procps/top.c b/procps/top.c index 8e5767e41..f6bbb23cd 100644 --- a/procps/top.c +++ b/procps/top.c | |||
@@ -212,6 +212,8 @@ static void read_status(int num, status_t *s) | |||
212 | fp = fopen(status, "r"); | 212 | fp = fopen(status, "r"); |
213 | if (!fp) { | 213 | if (!fp) { |
214 | strncpy(s->pid, "EXIT", sizeof(s->pid)); | 214 | strncpy(s->pid, "EXIT", sizeof(s->pid)); |
215 | s->pid[sizeof(s->pid)-1] = '\0'; | ||
216 | fclose(fp); | ||
215 | continue; | 217 | continue; |
216 | } | 218 | } |
217 | 219 | ||
@@ -296,6 +298,7 @@ static status_t *read_info(int num, struct dirent **namelist) | |||
296 | sprintf(cmdline, "%s/cmdline", s->pid); | 298 | sprintf(cmdline, "%s/cmdline", s->pid); |
297 | fp = fopen(cmdline, "r"); | 299 | fp = fopen(cmdline, "r"); |
298 | if (!fp) { | 300 | if (!fp) { |
301 | fclose(fp); | ||
299 | perror("fopen('cmdline')"); | 302 | perror("fopen('cmdline')"); |
300 | return NULL; | 303 | return NULL; |
301 | } | 304 | } |