Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
adam.huang
htop
Commits
d64f2bdd
Commit
d64f2bdd
authored
Mar 31, 2016
by
Hisham
Browse files
If task_for_pid fails, stop trying.
parent
3a4c0fa2
Changes
1
Hide whitespace changes
Inline
Side-by-side
darwin/DarwinProcess.c
View file @
d64f2bdd
...
...
@@ -26,6 +26,7 @@ typedef struct DarwinProcess_ {
uint64_t utime;
uint64_t stime;
bool taskAccess;
} DarwinProcess;
}*/
...
...
@@ -47,6 +48,7 @@ DarwinProcess* DarwinProcess_new(Settings* settings) {
this
->
utime
=
0
;
this
->
stime
=
0
;
this
->
taskAccess
=
true
;
return
this
;
}
...
...
@@ -301,6 +303,10 @@ void DarwinProcess_scanThreads(DarwinProcess *dp) {
Process
*
proc
=
(
Process
*
)
dp
;
kern_return_t
ret
;
if
(
!
dp
->
taskAccess
)
{
return
;
}
if
(
proc
->
state
==
'Z'
)
{
return
;
}
...
...
@@ -308,6 +314,7 @@ void DarwinProcess_scanThreads(DarwinProcess *dp) {
task_t
port
;
ret
=
task_for_pid
(
mach_task_self
(),
proc
->
pid
,
&
port
);
if
(
ret
!=
KERN_SUCCESS
)
{
dp
->
taskAccess
=
false
;
return
;
}
...
...
@@ -315,6 +322,7 @@ void DarwinProcess_scanThreads(DarwinProcess *dp) {
mach_msg_type_number_t
task_info_count
=
TASK_INFO_MAX
;
ret
=
task_info
(
port
,
TASK_BASIC_INFO
,
(
task_info_t
)
tinfo
,
&
task_info_count
);
if
(
ret
!=
KERN_SUCCESS
)
{
dp
->
taskAccess
=
false
;
return
;
}
...
...
@@ -322,6 +330,7 @@ void DarwinProcess_scanThreads(DarwinProcess *dp) {
mach_msg_type_number_t
thread_count
;
ret
=
task_threads
(
port
,
&
thread_list
,
&
thread_count
);
if
(
ret
!=
KERN_SUCCESS
)
{
dp
->
taskAccess
=
false
;
mach_port_deallocate
(
mach_task_self
(),
port
);
return
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment