Are tid and tgid always the same as pid in the output of ps?
In manpage of ps
tid TID the unique number representing a dispatchable
entity (alias lwp, spid). This value may also
appear as: a process ID (pid); a process group
ID (pgrp); a session ID for the session leader
(sid); a thread group ID for the thread group
leader (tgid); and a tty process group ID for
the process group leader (tpgid).
tgid TGID a number representing the thread group to which
a task belongs (alias pid). It is the process
ID of the thread group leader.
In Ubuntu, tid and tgid seem always the same as pid, for both user processes, and kernel threads (I run ps -o pid,tid,tgid,cmd
) Is it true in Linux, and why?
Is it true in other Unix such as System V or BSD?
Thanks.
linux ps thread system-v
add a comment |
In manpage of ps
tid TID the unique number representing a dispatchable
entity (alias lwp, spid). This value may also
appear as: a process ID (pid); a process group
ID (pgrp); a session ID for the session leader
(sid); a thread group ID for the thread group
leader (tgid); and a tty process group ID for
the process group leader (tpgid).
tgid TGID a number representing the thread group to which
a task belongs (alias pid). It is the process
ID of the thread group leader.
In Ubuntu, tid and tgid seem always the same as pid, for both user processes, and kernel threads (I run ps -o pid,tid,tgid,cmd
) Is it true in Linux, and why?
Is it true in other Unix such as System V or BSD?
Thanks.
linux ps thread system-v
add a comment |
In manpage of ps
tid TID the unique number representing a dispatchable
entity (alias lwp, spid). This value may also
appear as: a process ID (pid); a process group
ID (pgrp); a session ID for the session leader
(sid); a thread group ID for the thread group
leader (tgid); and a tty process group ID for
the process group leader (tpgid).
tgid TGID a number representing the thread group to which
a task belongs (alias pid). It is the process
ID of the thread group leader.
In Ubuntu, tid and tgid seem always the same as pid, for both user processes, and kernel threads (I run ps -o pid,tid,tgid,cmd
) Is it true in Linux, and why?
Is it true in other Unix such as System V or BSD?
Thanks.
linux ps thread system-v
In manpage of ps
tid TID the unique number representing a dispatchable
entity (alias lwp, spid). This value may also
appear as: a process ID (pid); a process group
ID (pgrp); a session ID for the session leader
(sid); a thread group ID for the thread group
leader (tgid); and a tty process group ID for
the process group leader (tpgid).
tgid TGID a number representing the thread group to which
a task belongs (alias pid). It is the process
ID of the thread group leader.
In Ubuntu, tid and tgid seem always the same as pid, for both user processes, and kernel threads (I run ps -o pid,tid,tgid,cmd
) Is it true in Linux, and why?
Is it true in other Unix such as System V or BSD?
Thanks.
linux ps thread system-v
linux ps thread system-v
edited 2 days ago
ctrl-alt-delor
10.9k41957
10.9k41957
asked 2 days ago
Tim
26k74246455
26k74246455
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
You need to task ps
to show thread information; otherwise it only lists processes:
ps -eL -o pid,tid,comm | awk '$1 != $2'
will show all the threads, apart from each process’ main thread, i.e. entries in the process table where pid and tid are different. The significant option is -L
: without that, ps
will only list entries where pid and tid are identical.
On FreeBSD, the equivalent option is -H
. I haven’t checked other BSDs, or System V.
Hmm…this actually doesn't give an answer. Are they the same or not.
– 炸鱼薯条德里克
2 days ago
1
@炸鱼薯条德里克awk '$1 != $2'
should give a strong hint, but I’ve clarified that part.
– Stephen Kitt
2 days ago
Thanks. "On FreeBSD, the equivalent option is -H". BSD style option doesn't have dash, does it?
– Tim
2 days ago
1
@Tim: Linux ps doesn't use a dash, but the actual FreeBSD ps accepts both kinds (because it doesn't have to distinguish: all options in FreeBSD ps are "BSD style" options) and the manual page actually documents them with a dash.
– grawity
2 days ago
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "106"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
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
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f491508%2fare-tid-and-tgid-always-the-same-as-pid-in-the-output-of-ps%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
You need to task ps
to show thread information; otherwise it only lists processes:
ps -eL -o pid,tid,comm | awk '$1 != $2'
will show all the threads, apart from each process’ main thread, i.e. entries in the process table where pid and tid are different. The significant option is -L
: without that, ps
will only list entries where pid and tid are identical.
On FreeBSD, the equivalent option is -H
. I haven’t checked other BSDs, or System V.
Hmm…this actually doesn't give an answer. Are they the same or not.
– 炸鱼薯条德里克
2 days ago
1
@炸鱼薯条德里克awk '$1 != $2'
should give a strong hint, but I’ve clarified that part.
– Stephen Kitt
2 days ago
Thanks. "On FreeBSD, the equivalent option is -H". BSD style option doesn't have dash, does it?
– Tim
2 days ago
1
@Tim: Linux ps doesn't use a dash, but the actual FreeBSD ps accepts both kinds (because it doesn't have to distinguish: all options in FreeBSD ps are "BSD style" options) and the manual page actually documents them with a dash.
– grawity
2 days ago
add a comment |
You need to task ps
to show thread information; otherwise it only lists processes:
ps -eL -o pid,tid,comm | awk '$1 != $2'
will show all the threads, apart from each process’ main thread, i.e. entries in the process table where pid and tid are different. The significant option is -L
: without that, ps
will only list entries where pid and tid are identical.
On FreeBSD, the equivalent option is -H
. I haven’t checked other BSDs, or System V.
Hmm…this actually doesn't give an answer. Are they the same or not.
– 炸鱼薯条德里克
2 days ago
1
@炸鱼薯条德里克awk '$1 != $2'
should give a strong hint, but I’ve clarified that part.
– Stephen Kitt
2 days ago
Thanks. "On FreeBSD, the equivalent option is -H". BSD style option doesn't have dash, does it?
– Tim
2 days ago
1
@Tim: Linux ps doesn't use a dash, but the actual FreeBSD ps accepts both kinds (because it doesn't have to distinguish: all options in FreeBSD ps are "BSD style" options) and the manual page actually documents them with a dash.
– grawity
2 days ago
add a comment |
You need to task ps
to show thread information; otherwise it only lists processes:
ps -eL -o pid,tid,comm | awk '$1 != $2'
will show all the threads, apart from each process’ main thread, i.e. entries in the process table where pid and tid are different. The significant option is -L
: without that, ps
will only list entries where pid and tid are identical.
On FreeBSD, the equivalent option is -H
. I haven’t checked other BSDs, or System V.
You need to task ps
to show thread information; otherwise it only lists processes:
ps -eL -o pid,tid,comm | awk '$1 != $2'
will show all the threads, apart from each process’ main thread, i.e. entries in the process table where pid and tid are different. The significant option is -L
: without that, ps
will only list entries where pid and tid are identical.
On FreeBSD, the equivalent option is -H
. I haven’t checked other BSDs, or System V.
edited 2 days ago
answered 2 days ago
Stephen Kitt
164k24365444
164k24365444
Hmm…this actually doesn't give an answer. Are they the same or not.
– 炸鱼薯条德里克
2 days ago
1
@炸鱼薯条德里克awk '$1 != $2'
should give a strong hint, but I’ve clarified that part.
– Stephen Kitt
2 days ago
Thanks. "On FreeBSD, the equivalent option is -H". BSD style option doesn't have dash, does it?
– Tim
2 days ago
1
@Tim: Linux ps doesn't use a dash, but the actual FreeBSD ps accepts both kinds (because it doesn't have to distinguish: all options in FreeBSD ps are "BSD style" options) and the manual page actually documents them with a dash.
– grawity
2 days ago
add a comment |
Hmm…this actually doesn't give an answer. Are they the same or not.
– 炸鱼薯条德里克
2 days ago
1
@炸鱼薯条德里克awk '$1 != $2'
should give a strong hint, but I’ve clarified that part.
– Stephen Kitt
2 days ago
Thanks. "On FreeBSD, the equivalent option is -H". BSD style option doesn't have dash, does it?
– Tim
2 days ago
1
@Tim: Linux ps doesn't use a dash, but the actual FreeBSD ps accepts both kinds (because it doesn't have to distinguish: all options in FreeBSD ps are "BSD style" options) and the manual page actually documents them with a dash.
– grawity
2 days ago
Hmm…this actually doesn't give an answer. Are they the same or not.
– 炸鱼薯条德里克
2 days ago
Hmm…this actually doesn't give an answer. Are they the same or not.
– 炸鱼薯条德里克
2 days ago
1
1
@炸鱼薯条德里克
awk '$1 != $2'
should give a strong hint, but I’ve clarified that part.– Stephen Kitt
2 days ago
@炸鱼薯条德里克
awk '$1 != $2'
should give a strong hint, but I’ve clarified that part.– Stephen Kitt
2 days ago
Thanks. "On FreeBSD, the equivalent option is -H". BSD style option doesn't have dash, does it?
– Tim
2 days ago
Thanks. "On FreeBSD, the equivalent option is -H". BSD style option doesn't have dash, does it?
– Tim
2 days ago
1
1
@Tim: Linux ps doesn't use a dash, but the actual FreeBSD ps accepts both kinds (because it doesn't have to distinguish: all options in FreeBSD ps are "BSD style" options) and the manual page actually documents them with a dash.
– grawity
2 days ago
@Tim: Linux ps doesn't use a dash, but the actual FreeBSD ps accepts both kinds (because it doesn't have to distinguish: all options in FreeBSD ps are "BSD style" options) and the manual page actually documents them with a dash.
– grawity
2 days ago
add a comment |
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
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
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f491508%2fare-tid-and-tgid-always-the-same-as-pid-in-the-output-of-ps%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
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
Required, but never shown
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
Required, but never shown
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
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown