Get PID from TID
Clash Royale CLAN TAG#URR8PPP
up vote
3
down vote
favorite
I run iotop
to check on programs that are heavy disk users, in case I need to decrease their priority. Usually this is good enough, but iotop
only shows thread ID (TID), and sometimes I want to know process ID (PID) so I can find out more about which process is responsible.
Unfortunately, while ps
can display TID (a.k.a SPID, LWP), it doesn't have a flag to take a list of TIDs the way it does for a list of PIDs with --pid
. The best I can do is list TIDs and then grep
the output. For example, if the thread id is 792, I can do
$ ps -eLf | grep ' 792 '
which works reasonably well, but is a little inelegant.
Is there a better way?
ps thread pthreads
add a comment |Â
up vote
3
down vote
favorite
I run iotop
to check on programs that are heavy disk users, in case I need to decrease their priority. Usually this is good enough, but iotop
only shows thread ID (TID), and sometimes I want to know process ID (PID) so I can find out more about which process is responsible.
Unfortunately, while ps
can display TID (a.k.a SPID, LWP), it doesn't have a flag to take a list of TIDs the way it does for a list of PIDs with --pid
. The best I can do is list TIDs and then grep
the output. For example, if the thread id is 792, I can do
$ ps -eLf | grep ' 792 '
which works reasonably well, but is a little inelegant.
Is there a better way?
ps thread pthreads
add a comment |Â
up vote
3
down vote
favorite
up vote
3
down vote
favorite
I run iotop
to check on programs that are heavy disk users, in case I need to decrease their priority. Usually this is good enough, but iotop
only shows thread ID (TID), and sometimes I want to know process ID (PID) so I can find out more about which process is responsible.
Unfortunately, while ps
can display TID (a.k.a SPID, LWP), it doesn't have a flag to take a list of TIDs the way it does for a list of PIDs with --pid
. The best I can do is list TIDs and then grep
the output. For example, if the thread id is 792, I can do
$ ps -eLf | grep ' 792 '
which works reasonably well, but is a little inelegant.
Is there a better way?
ps thread pthreads
I run iotop
to check on programs that are heavy disk users, in case I need to decrease their priority. Usually this is good enough, but iotop
only shows thread ID (TID), and sometimes I want to know process ID (PID) so I can find out more about which process is responsible.
Unfortunately, while ps
can display TID (a.k.a SPID, LWP), it doesn't have a flag to take a list of TIDs the way it does for a list of PIDs with --pid
. The best I can do is list TIDs and then grep
the output. For example, if the thread id is 792, I can do
$ ps -eLf | grep ' 792 '
which works reasonably well, but is a little inelegant.
Is there a better way?
ps thread pthreads
asked Mar 15 at 16:35
Nathaniel M. Beaver
180115
180115
add a comment |Â
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
5
down vote
accepted
You can always do:
ps -eLo pid= -o tid= | awk '$2 == 792 print $1'
On Linux:
$ readlink -f /proc/*/task/792/../..
/proc/300
Or with zsh
:
$ echo /proc/*/task/792(:h:h:t)
300
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
5
down vote
accepted
You can always do:
ps -eLo pid= -o tid= | awk '$2 == 792 print $1'
On Linux:
$ readlink -f /proc/*/task/792/../..
/proc/300
Or with zsh
:
$ echo /proc/*/task/792(:h:h:t)
300
add a comment |Â
up vote
5
down vote
accepted
You can always do:
ps -eLo pid= -o tid= | awk '$2 == 792 print $1'
On Linux:
$ readlink -f /proc/*/task/792/../..
/proc/300
Or with zsh
:
$ echo /proc/*/task/792(:h:h:t)
300
add a comment |Â
up vote
5
down vote
accepted
up vote
5
down vote
accepted
You can always do:
ps -eLo pid= -o tid= | awk '$2 == 792 print $1'
On Linux:
$ readlink -f /proc/*/task/792/../..
/proc/300
Or with zsh
:
$ echo /proc/*/task/792(:h:h:t)
300
You can always do:
ps -eLo pid= -o tid= | awk '$2 == 792 print $1'
On Linux:
$ readlink -f /proc/*/task/792/../..
/proc/300
Or with zsh
:
$ echo /proc/*/task/792(:h:h:t)
300
answered Mar 15 at 16:58
Stéphane Chazelas
280k53515847
280k53515847
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f430428%2fget-pid-from-tid%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password