Added error checking of the return value of get_sem_info().
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24023 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
+7
-5
@@ -21,7 +21,6 @@
|
|||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
status_t ret;
|
|
||||||
team_info teaminfo;
|
team_info teaminfo;
|
||||||
thread_info thinfo;
|
thread_info thinfo;
|
||||||
uint32 teamcookie = 0;
|
uint32 teamcookie = 0;
|
||||||
@@ -36,7 +35,7 @@ int main(int argc, char **argv)
|
|||||||
puts("");
|
puts("");
|
||||||
puts(PS_HEADER);
|
puts(PS_HEADER);
|
||||||
puts(PS_SEP);
|
puts(PS_SEP);
|
||||||
while ((ret = get_next_team_info(&teamcookie, &teaminfo)) >= B_OK) {
|
while (get_next_team_info(&teamcookie, &teaminfo) >= B_OK) {
|
||||||
if (string_to_match) {
|
if (string_to_match) {
|
||||||
char *p;
|
char *p;
|
||||||
p = teaminfo.args;
|
p = teaminfo.args;
|
||||||
@@ -50,15 +49,18 @@ int main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
printf("%s (team %ld) (uid %d) (gid %d)\n", teaminfo.args, teaminfo.team, teaminfo.uid, teaminfo.gid);
|
printf("%s (team %ld) (uid %d) (gid %d)\n", teaminfo.args, teaminfo.team, teaminfo.uid, teaminfo.gid);
|
||||||
thcookie = 0;
|
thcookie = 0;
|
||||||
while ((ret = get_next_thread_info(teaminfo.team, &thcookie, &thinfo)) >= B_OK) {
|
while (get_next_thread_info(teaminfo.team, &thcookie, &thinfo) >= B_OK) {
|
||||||
if (thinfo.state < B_THREAD_RUNNING || thinfo.state >B_THREAD_WAITING)
|
if (thinfo.state < B_THREAD_RUNNING || thinfo.state >B_THREAD_WAITING)
|
||||||
thstate = "???";
|
thstate = "???";
|
||||||
else
|
else
|
||||||
thstate = states[thinfo.state-1];
|
thstate = states[thinfo.state-1];
|
||||||
printf("%7ld %20s %3s %3ld %7lli %7lli ", thinfo.thread, thinfo.name, thstate, thinfo.priority, thinfo.user_time/1000, thinfo.kernel_time/1000);
|
printf("%7ld %20s %3s %3ld %7lli %7lli ", thinfo.thread, thinfo.name, thstate, thinfo.priority, thinfo.user_time/1000, thinfo.kernel_time/1000);
|
||||||
if (thinfo.state == B_THREAD_WAITING) {
|
if (thinfo.state == B_THREAD_WAITING) {
|
||||||
get_sem_info(thinfo.sem, &sinfo);
|
status_t err = get_sem_info(thinfo.sem, &sinfo);
|
||||||
printf("%s(%ld)\n", sinfo.name, sinfo.sem);
|
if (!err)
|
||||||
|
printf("%s(%ld)\n", sinfo.name, sinfo.sem);
|
||||||
|
else
|
||||||
|
printf("%s(%ld)\n", strerror(err), thinfo.sem);
|
||||||
} else
|
} else
|
||||||
puts("");
|
puts("");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user