| 519 | } |
| 520 | |
| 521 | Status ListThreads(vector<pid_t> *tids) { |
| 522 | #ifndef __linux__ |
| 523 | return Status::NotSupported("unable to list threads on this platform"); |
| 524 | #else |
| 525 | DIR *dir = opendir("/proc/self/task/"); |
| 526 | if (dir == NULL) { |
| 527 | return Status::IOError("failed to open task dir", ErrnoToString(errno), errno); |
| 528 | } |
| 529 | struct dirent *d; |
| 530 | while ((d = readdir(dir)) != NULL) { |
| 531 | if (d->d_name[0] != '.') { |
| 532 | uint32_t tid; |
| 533 | if (!safe_strtou32(d->d_name, &tid)) { |
| 534 | LOG(WARNING) << "bad tid found in procfs: " << d->d_name; |
| 535 | continue; |
| 536 | } |
| 537 | tids->push_back(tid); |
| 538 | } |
| 539 | } |
| 540 | closedir(dir); |
| 541 | return Status::OK(); |
| 542 | #endif // __linux__ |
| 543 | } |
| 544 | |
| 545 | string GetStackTrace() { |
| 546 | string s; |