Skip to contentSkip to conversation

why switch_exec_pids() changes thread group leader pid?

Q Kirill Korotaev 2 participants 4 messages Sep 20, 2004

lore
Share & tools
lore
#0 lore raw

Hello,

I've been looking through switch_exec_pids() function and found that it changes thread group leader PID/TGID. Is it really a good idea to change
pid of the process during it's lifetime? I could understand if it was
happenning in the context of that process, but pid changes everytime a thread calls do_execve().

As far as I can see, leader doesn't have to do any of detach_pid()'s. Instead thread should change it's PID/TGID.

Am I wrong?

Kirill

#1 lore raw
Quoted 7 lines · Kirill Korotaev

I've been looking through switch_exec_pids() function and found that it changes thread group leader PID/TGID. Is it really a good idea to change
pid of the process during it's lifetime? I could understand if it was
happenning in the context of that process, but pid changes everytime a thread calls do_execve().
As far as I can see, leader doesn't have to do any of detach_pid()'s. Instead thread should change it's PID/TGID.

It's only done when a thread that is not a thread group leader execve()'s. This is actually pretty rare and confined to threaded applications, so it should be almost never called.

-- wli

#2 lore raw
Quoted 9 lines · William Lee Irwin III
Quoted 2 lines · Kirill Korotaev

I've been looking through switch_exec_pids() function and found that it changes thread group leader PID/TGID. Is it really a good idea to change pid of the process during it's lifetime? I could understand if it was happenning in the context of that process, but pid changes everytime a thread calls do_execve(). As far as I can see, leader doesn't have to do any of detach_pid()'s. Instead thread should change it's PID/TGID.

It's only done when a thread that is not a thread group leader execve()'s. This is actually pretty rare and confined to threaded applications, so it should be almost never called.

Heh, rare doesn't mean correct, yeah? :)

Kirill

#3 lore raw
Quoted 7 lines · Kirill Korotaev
Quoted 7 lines
Quoted 7 lines

I've been looking through switch_exec_pids() function and found that it changes thread group leader PID/TGID. Is it really a good idea to change pid of the process during it's lifetime? I could understand if it was happenning in the context of that process, but pid changes everytime a thread calls do_execve().
As far as I can see, leader doesn't have to do any of detach_pid()'s. Instead thread should change it's PID/TGID.

Quoted 3 lines · William Lee Irwin III
Quoted 3 lines

It's only done when a thread that is not a thread group leader execve()'s. This is actually pretty rare and confined to threaded applications, so it should be almost never called.

Quoted 1 line · Kirill Korotaev

Heh, rare doesn't mean correct, yeah? :)

The semantic it implements is that the thread calling execve() kills all other threads of the process and assumes the identity of the thread group leader. It should be clear that when the thread were already the group leader, such as it is for unthreaded processes, one need only kill the other threads, of which there are none for unthreaded processes. I'm largely not involved with the implementation of POSIX threading semantics, so there is some limit regarding the amount of detail in which I can go on about it without resorting to research.

Ingo Molnar, Roland McGrath, and Ulrich Drepper will likely have more information if you should care to question so deeply as to ask e.g. whether this is actually faithful to whatever standard they followed.

-- wli