From de11935fd3dbb605891a6f16763329fbdc9c43a4 Mon Sep 17 00:00:00 2001 From: Nick Alcock Date: Mon, 17 Mar 2014 16:29:34 +0000 Subject: [PATCH] Fix the pid and ppid variables in multithreaded processes. pid is currently equal to the Linux-side PID: i.e., from userspace's perspective, the thread ID. tgid is equal to the thread ID of the parent. Both of these are at best inconvenient and at worst wrong: they should both use the thread group ID of their respective task, which corresponds to the userspace-visible PID. Orabug: 18412802 Signed-off-by: Nick Alcock Reviewed-by: Kris Van Hees --- dtrace/dtrace_dif.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dtrace/dtrace_dif.c b/dtrace/dtrace_dif.c index 0d0020bb9f3e..52816e942043 100644 --- a/dtrace/dtrace_dif.c +++ b/dtrace/dtrace_dif.c @@ -2243,7 +2243,7 @@ static uint64_t dtrace_dif_variable(dtrace_mstate_t *mstate, * It is always safe to dereference current, it always points * to a valid task_struct. */ - return (uint64_t)current->pid; + return (uint64_t)current->tgid; case DIF_VAR_PPID: if (!dtrace_priv_proc(state)) @@ -2256,7 +2256,7 @@ static uint64_t dtrace_dif_variable(dtrace_mstate_t *mstate, * Additionally, it is safe to dereference one's parent, since * it is never NULL after process birth. */ - return (uint64_t)current->real_parent->pid; + return (uint64_t)current->real_parent->tgid; case DIF_VAR_TID: return (uint64_t)current->pid; -- 2.50.1