diff options
Diffstat (limited to 'tools/perf/util/thread.c')
| -rw-r--r-- | tools/perf/util/thread.c | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/tools/perf/util/thread.c b/tools/perf/util/thread.c index 1f7ecd47f499..8c72d888e449 100644 --- a/tools/perf/util/thread.c +++ b/tools/perf/util/thread.c | |||
| @@ -7,6 +7,15 @@ | |||
| 7 | #include "util.h" | 7 | #include "util.h" |
| 8 | #include "debug.h" | 8 | #include "debug.h" |
| 9 | 9 | ||
| 10 | /* Skip "." and ".." directories */ | ||
| 11 | static int filter(const struct dirent *dir) | ||
| 12 | { | ||
| 13 | if (dir->d_name[0] == '.') | ||
| 14 | return 0; | ||
| 15 | else | ||
| 16 | return 1; | ||
| 17 | } | ||
| 18 | |||
| 10 | int find_all_tid(int pid, pid_t ** all_tid) | 19 | int find_all_tid(int pid, pid_t ** all_tid) |
| 11 | { | 20 | { |
| 12 | char name[256]; | 21 | char name[256]; |
| @@ -16,7 +25,7 @@ int find_all_tid(int pid, pid_t ** all_tid) | |||
| 16 | int i; | 25 | int i; |
| 17 | 26 | ||
| 18 | sprintf(name, "/proc/%d/task", pid); | 27 | sprintf(name, "/proc/%d/task", pid); |
| 19 | items = scandir(name, &namelist, NULL, NULL); | 28 | items = scandir(name, &namelist, filter, NULL); |
| 20 | if (items <= 0) | 29 | if (items <= 0) |
| 21 | return -ENOENT; | 30 | return -ENOENT; |
| 22 | *all_tid = malloc(sizeof(pid_t) * items); | 31 | *all_tid = malloc(sizeof(pid_t) * items); |
| @@ -53,6 +62,13 @@ static struct thread *thread__new(pid_t pid) | |||
| 53 | return self; | 62 | return self; |
| 54 | } | 63 | } |
| 55 | 64 | ||
| 65 | void thread__delete(struct thread *self) | ||
| 66 | { | ||
| 67 | map_groups__exit(&self->mg); | ||
| 68 | free(self->comm); | ||
| 69 | free(self); | ||
| 70 | } | ||
| 71 | |||
| 56 | int thread__set_comm(struct thread *self, const char *comm) | 72 | int thread__set_comm(struct thread *self, const char *comm) |
| 57 | { | 73 | { |
| 58 | int err; | 74 | int err; |
