From: Nick Alcock Date: Mon, 17 Mar 2014 16:29:34 +0000 (+0000) Subject: Fix the pid and ppid variables in multithreaded processes. X-Git-Tag: v4.1.12-111.0.20170907_2225~3^2~3^2~94 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=de11935fd3dbb605891a6f16763329fbdc9c43a4;p=users%2Fjedix%2Flinux-maple.git 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 --- diff --git a/dtrace/dtrace_dif.c b/dtrace/dtrace_dif.c index 0d0020bb9f3ec..52816e9420431 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;