How can I view threads for a running process that is creating threads?
0
votes
1
answer
2270
views
I made a very small program that creates two threads:
#include
#include
#include
void *start()
{
printf("Am a new thread!\n");
printf("%d\n",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?
Asked by alkabary
(1539 rep)
Apr 4, 2019, 09:27 PM
Last activity: Jul 3, 2025, 02:02 AM
Last activity: Jul 3, 2025, 02:02 AM