How can I view threads for a running process that is creating threads?How can i get the process with the biggest pid?How can I see i/o stats for a briefly running process?How I can identify that a process has multiple instancesCheck for process and kill if runningShow running processes only — *not* threadsHow to ensure exclusive CPU availability for a running process?What is a limit for number of threads?How to get the process that is runningGet list of processes that were forked off my currently running process?How to kill and rerun process in one command in Linux
TGV timetables / schedules?
Shell script can be run only with sh command
Why is the design of haulage companies so “special”?
How to report a triplet of septets in NMR tabulation?
Prevent a directory in /tmp from being deleted
A newer friend of my brother's gave him a load of baseball cards that are supposedly extremely valuable. Is this a scam?
Why Is Death Allowed In the Matrix?
GPS Rollover on Android Smartphones
How is it possible to have an ability score that is less than 3?
Motorized valve interfering with button?
How is this relation reflexive?
Do Phineas and Ferb ever actually get busted in real time?
How to type dʒ symbol (IPA) on Mac?
Why has Russell's definition of numbers using equivalence classes been finally abandoned? ( If it has actually been abandoned).
How to get the available space of $HOME as a variable in shell scripting?
What do you call something that goes against the spirit of the law, but is legal when interpreting the law to the letter?
If Manufacturer spice model and Datasheet give different values which should I use?
"You are your self first supporter", a more proper way to say it
What would happen to a modern skyscraper if it rains micro blackholes?
Is there really no realistic way for a skeleton monster to move around without magic?
"which" command doesn't work / path of Safari?
Banach space and Hilbert space topology
How do we improve the relationship with a client software team that performs poorly and is becoming less collaborative?
Is there a familial term for apples and pears?
How can I view threads for a running process that is creating threads?
How can i get the process with the biggest pid?How can I see i/o stats for a briefly running process?How I can identify that a process has multiple instancesCheck for process and kill if runningShow running processes only — *not* threadsHow to ensure exclusive CPU availability for a running process?What is a limit for number of threads?How to get the process that is runningGet list of processes that were forked off my currently running process?How to kill and rerun process in one command in Linux
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I made a very small program that creates two threads:
#include <pthread.h>
#include <stdio.h>
#include <unistd.h>
void *start()
printf("Am a new thread!n");
printf("%dn",pthread_self());
void main()
pthread_t thread_id1;
pthread_t thread_id2;
pthread_create(&thread_id1,NULL,start,NULL);
pthread_create(&thread_id2,NULL,start,NULL);
//pthread_join(thread_id,NULL);
sleep(30);
When I compile and run the program with:
gcc create.c -lpthread
./a.out
And I open a new terminal and try to view the threads, this is what I get:
ps -efL | grep a.out
root 1943 20158 1943 0 1 15:25 pts/4 00:00:00 ./a.out
root 1985 1889 1985 0 1 15:25 pts/5 00:00:00 grep --color=auto a.out
So why can't I see two thread ids here?
linux-kernel ps process-management pthreads
add a comment |
I made a very small program that creates two threads:
#include <pthread.h>
#include <stdio.h>
#include <unistd.h>
void *start()
printf("Am a new thread!n");
printf("%dn",pthread_self());
void main()
pthread_t thread_id1;
pthread_t thread_id2;
pthread_create(&thread_id1,NULL,start,NULL);
pthread_create(&thread_id2,NULL,start,NULL);
//pthread_join(thread_id,NULL);
sleep(30);
When I compile and run the program with:
gcc create.c -lpthread
./a.out
And I open a new terminal and try to view the threads, this is what I get:
ps -efL | grep a.out
root 1943 20158 1943 0 1 15:25 pts/4 00:00:00 ./a.out
root 1985 1889 1985 0 1 15:25 pts/5 00:00:00 grep --color=auto a.out
So why can't I see two thread ids here?
linux-kernel ps process-management pthreads
add a comment |
I made a very small program that creates two threads:
#include <pthread.h>
#include <stdio.h>
#include <unistd.h>
void *start()
printf("Am a new thread!n");
printf("%dn",pthread_self());
void main()
pthread_t thread_id1;
pthread_t thread_id2;
pthread_create(&thread_id1,NULL,start,NULL);
pthread_create(&thread_id2,NULL,start,NULL);
//pthread_join(thread_id,NULL);
sleep(30);
When I compile and run the program with:
gcc create.c -lpthread
./a.out
And I open a new terminal and try to view the threads, this is what I get:
ps -efL | grep a.out
root 1943 20158 1943 0 1 15:25 pts/4 00:00:00 ./a.out
root 1985 1889 1985 0 1 15:25 pts/5 00:00:00 grep --color=auto a.out
So why can't I see two thread ids here?
linux-kernel ps process-management pthreads
I made a very small program that creates two threads:
#include <pthread.h>
#include <stdio.h>
#include <unistd.h>
void *start()
printf("Am a new thread!n");
printf("%dn",pthread_self());
void main()
pthread_t thread_id1;
pthread_t thread_id2;
pthread_create(&thread_id1,NULL,start,NULL);
pthread_create(&thread_id2,NULL,start,NULL);
//pthread_join(thread_id,NULL);
sleep(30);
When I compile and run the program with:
gcc create.c -lpthread
./a.out
And I open a new terminal and try to view the threads, this is what I get:
ps -efL | grep a.out
root 1943 20158 1943 0 1 15:25 pts/4 00:00:00 ./a.out
root 1985 1889 1985 0 1 15:25 pts/5 00:00:00 grep --color=auto a.out
So why can't I see two thread ids here?
linux-kernel ps process-management pthreads
linux-kernel ps process-management pthreads
asked Apr 4 at 21:27
alkabaryalkabary
61411124
61411124
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
The two additional threads write their message and terminate, so you don't have the time to see them with ps.
from man pthread_create:
The new thread terminates in one of the following ways:
*
It calls pthread_exit(3), specifying an exit status value that is available to another thread in the same process that calls
pthread_join(3).
*
It returns from start_routine(). This is equivalent to calling pthread_exit(3) with the value supplied in the return statement.
[...]
You can follow what's going on for example with strace:
$ strace -f -e trace=clone,exit ./a.out
clone(strace: Process 409 attached
child_stack=0x7f7126930ff0, flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM|CLONE_SETTLS|CLONE_PARENT_SETTID|CLONE_CHILD_CLEARTID, parent_tidptr=0x7f71269319d0, tls=0x7f7126931700, child_tidptr=0x7f71269319d0) = 409
[pid 408] clone(strace: Process 410 attached
child_stack=0x7f712612fff0, flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM|CLONE_SETTLS|CLONE_PARENT_SETTID|CLONE_CHILD_CLEARTID, parent_tidptr=0x7f71261309d0, tls=0x7f7126130700, child_tidptr=0x7f71261309d0) = 410
Am a new thread!
Am a new thread!
647173888
638781184
[pid 409] exit(0 <unfinished ...>
[pid 410] exit(0 <unfinished ...>
[pid 409] <... exit resumed>) = ?
[pid 410] <... exit resumed>) = ?
[pid 410] +++ exited with 0 +++
[pid 409] +++ exited with 0 +++
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%2f510588%2fhow-can-i-view-threads-for-a-running-process-that-is-creating-threads%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
The two additional threads write their message and terminate, so you don't have the time to see them with ps.
from man pthread_create:
The new thread terminates in one of the following ways:
*
It calls pthread_exit(3), specifying an exit status value that is available to another thread in the same process that calls
pthread_join(3).
*
It returns from start_routine(). This is equivalent to calling pthread_exit(3) with the value supplied in the return statement.
[...]
You can follow what's going on for example with strace:
$ strace -f -e trace=clone,exit ./a.out
clone(strace: Process 409 attached
child_stack=0x7f7126930ff0, flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM|CLONE_SETTLS|CLONE_PARENT_SETTID|CLONE_CHILD_CLEARTID, parent_tidptr=0x7f71269319d0, tls=0x7f7126931700, child_tidptr=0x7f71269319d0) = 409
[pid 408] clone(strace: Process 410 attached
child_stack=0x7f712612fff0, flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM|CLONE_SETTLS|CLONE_PARENT_SETTID|CLONE_CHILD_CLEARTID, parent_tidptr=0x7f71261309d0, tls=0x7f7126130700, child_tidptr=0x7f71261309d0) = 410
Am a new thread!
Am a new thread!
647173888
638781184
[pid 409] exit(0 <unfinished ...>
[pid 410] exit(0 <unfinished ...>
[pid 409] <... exit resumed>) = ?
[pid 410] <... exit resumed>) = ?
[pid 410] +++ exited with 0 +++
[pid 409] +++ exited with 0 +++
add a comment |
The two additional threads write their message and terminate, so you don't have the time to see them with ps.
from man pthread_create:
The new thread terminates in one of the following ways:
*
It calls pthread_exit(3), specifying an exit status value that is available to another thread in the same process that calls
pthread_join(3).
*
It returns from start_routine(). This is equivalent to calling pthread_exit(3) with the value supplied in the return statement.
[...]
You can follow what's going on for example with strace:
$ strace -f -e trace=clone,exit ./a.out
clone(strace: Process 409 attached
child_stack=0x7f7126930ff0, flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM|CLONE_SETTLS|CLONE_PARENT_SETTID|CLONE_CHILD_CLEARTID, parent_tidptr=0x7f71269319d0, tls=0x7f7126931700, child_tidptr=0x7f71269319d0) = 409
[pid 408] clone(strace: Process 410 attached
child_stack=0x7f712612fff0, flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM|CLONE_SETTLS|CLONE_PARENT_SETTID|CLONE_CHILD_CLEARTID, parent_tidptr=0x7f71261309d0, tls=0x7f7126130700, child_tidptr=0x7f71261309d0) = 410
Am a new thread!
Am a new thread!
647173888
638781184
[pid 409] exit(0 <unfinished ...>
[pid 410] exit(0 <unfinished ...>
[pid 409] <... exit resumed>) = ?
[pid 410] <... exit resumed>) = ?
[pid 410] +++ exited with 0 +++
[pid 409] +++ exited with 0 +++
add a comment |
The two additional threads write their message and terminate, so you don't have the time to see them with ps.
from man pthread_create:
The new thread terminates in one of the following ways:
*
It calls pthread_exit(3), specifying an exit status value that is available to another thread in the same process that calls
pthread_join(3).
*
It returns from start_routine(). This is equivalent to calling pthread_exit(3) with the value supplied in the return statement.
[...]
You can follow what's going on for example with strace:
$ strace -f -e trace=clone,exit ./a.out
clone(strace: Process 409 attached
child_stack=0x7f7126930ff0, flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM|CLONE_SETTLS|CLONE_PARENT_SETTID|CLONE_CHILD_CLEARTID, parent_tidptr=0x7f71269319d0, tls=0x7f7126931700, child_tidptr=0x7f71269319d0) = 409
[pid 408] clone(strace: Process 410 attached
child_stack=0x7f712612fff0, flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM|CLONE_SETTLS|CLONE_PARENT_SETTID|CLONE_CHILD_CLEARTID, parent_tidptr=0x7f71261309d0, tls=0x7f7126130700, child_tidptr=0x7f71261309d0) = 410
Am a new thread!
Am a new thread!
647173888
638781184
[pid 409] exit(0 <unfinished ...>
[pid 410] exit(0 <unfinished ...>
[pid 409] <... exit resumed>) = ?
[pid 410] <... exit resumed>) = ?
[pid 410] +++ exited with 0 +++
[pid 409] +++ exited with 0 +++
The two additional threads write their message and terminate, so you don't have the time to see them with ps.
from man pthread_create:
The new thread terminates in one of the following ways:
*
It calls pthread_exit(3), specifying an exit status value that is available to another thread in the same process that calls
pthread_join(3).
*
It returns from start_routine(). This is equivalent to calling pthread_exit(3) with the value supplied in the return statement.
[...]
You can follow what's going on for example with strace:
$ strace -f -e trace=clone,exit ./a.out
clone(strace: Process 409 attached
child_stack=0x7f7126930ff0, flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM|CLONE_SETTLS|CLONE_PARENT_SETTID|CLONE_CHILD_CLEARTID, parent_tidptr=0x7f71269319d0, tls=0x7f7126931700, child_tidptr=0x7f71269319d0) = 409
[pid 408] clone(strace: Process 410 attached
child_stack=0x7f712612fff0, flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM|CLONE_SETTLS|CLONE_PARENT_SETTID|CLONE_CHILD_CLEARTID, parent_tidptr=0x7f71261309d0, tls=0x7f7126130700, child_tidptr=0x7f71261309d0) = 410
Am a new thread!
Am a new thread!
647173888
638781184
[pid 409] exit(0 <unfinished ...>
[pid 410] exit(0 <unfinished ...>
[pid 409] <... exit resumed>) = ?
[pid 410] <... exit resumed>) = ?
[pid 410] +++ exited with 0 +++
[pid 409] +++ exited with 0 +++
answered 2 days ago
A.BA.B
5,94711030
5,94711030
add a comment |
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.
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%2f510588%2fhow-can-i-view-threads-for-a-running-process-that-is-creating-threads%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