fix reporting of fd
@@ -20,6 +20,7 @@ int osGetNumThreads(pid_t pid)
}
if (read(fd, buf, sizeof(buf)) == -1) {
+ close(fd);
return -1;
}
@@ -27,7 +28,7 @@ int osGetNumThreads(pid_t pid)
for (i = 1; i < 20; i++) {
entry = strtok(NULL, delim);
}
-
+ close(fd);
return atoi((const char *)entry);
}
@@ -50,7 +51,7 @@ int osGetNumFds(pid_t pid)
}
closedir(dirp);
- return nfile;
+ return nfile - 1; // we opened one fd to read /fd :)
}
int osGetNumChildProcs(pid_t pid)
