From 4a1f2d3866defbdc9386b52051c1d8540a8db451 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Thu, 31 Oct 2019 16:57:43 +0100 Subject: proc: do not set last_processor on thread_info() error * proc/info.c (S_proc_getprocinfo): Only set last_processor field when err == 0. --- proc/info.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'proc') diff --git a/proc/info.c b/proc/info.c index 93a18d39..6c2567d2 100644 --- a/proc/info.c +++ b/proc/info.c @@ -701,6 +701,15 @@ S_proc_getprocinfo (struct proc *callerp, err = thread_info (thds[i], THREAD_SCHED_INFO, (thread_info_t) &pi->threadinfos[i].pis_si, &thcount); + +#ifdef HAVE_STRUCT_THREAD_SCHED_INFO_LAST_PROCESSOR + if (err == 0) + /* If the structure read doesn't include last_processor field, assume + CPU 0. */ + if (thcount < 8) + pi->threadinfos[i].pis_si.last_processor = 0; +#endif + if (err == MACH_SEND_INVALID_DEST) { pi->threadinfos[i].died = 1; @@ -714,13 +723,6 @@ S_proc_getprocinfo (struct proc *callerp, err = 0; } -#ifdef HAVE_STRUCT_THREAD_SCHED_INFO_LAST_PROCESSOR - /* If the structure read doesn't include last_processor field, assume - CPU 0. */ - if (thcount < 8) - pi->threadinfos[i].pis_si.last_processor = 0; -#endif - } /* Note that there are thread wait entries only for those threads -- cgit v1.2.3