Skip to content

Commit af99886

Browse files
Daniel LangeDaniel Lange
authored andcommitted
Merge branch 'stuck-process' of aestriplex/htop
2 parents 8e3d714 + 617ef48 commit af99886

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

darwin/DarwinProcess.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -440,6 +440,7 @@ void DarwinProcess_scanThreads(DarwinProcess* dp, DarwinProcessTable* dpt) {
440440
}
441441

442442
const bool hideUserlandThreads = dpt->super.super.host->settings->hideUserlandThreads;
443+
bool isProcessStuck = false;
443444

444445
for (mach_msg_type_number_t i = 0; i < thread_count; i++) {
445446

@@ -490,6 +491,11 @@ void DarwinProcess_scanThreads(DarwinProcess* dp, DarwinProcessTable* dpt) {
490491
tdproc->super.time = (extended_info.pth_system_time + extended_info.pth_user_time) / 10000000;
491492
tdproc->super.priority = extended_info.pth_curpri;
492493

494+
if (extended_info.pth_run_state == TH_STATE_UNINTERRUPTIBLE) {
495+
isProcessStuck |= true;
496+
tdproc->super.state = UNINTERRUPTIBLE_WAIT;
497+
}
498+
493499
// TODO: depend on setting
494500
const char* name = extended_info.pth_name[0] != '\0' ? extended_info.pth_name : proc->procComm;
495501
Process_updateCmdline(tprocess, name, 0, strlen(name));
@@ -498,6 +504,10 @@ void DarwinProcess_scanThreads(DarwinProcess* dp, DarwinProcessTable* dpt) {
498504
ProcessTable_add(&dpt->super, tprocess);
499505
}
500506

507+
if (isProcessStuck) {
508+
dp->super.state = UNINTERRUPTIBLE_WAIT;
509+
}
510+
501511
vm_deallocate(mach_task_self(), (vm_address_t) thread_list, sizeof(thread_port_array_t) * thread_count);
502512
mach_port_deallocate(mach_task_self(), task);
503513
}

0 commit comments

Comments
 (0)