When I create a thread (pthread_create()
) from my main process, I see three (3) threads in the ps
listing, why is this? That is, I see the process for the main thread, one for the created thread, and third for something else. What is the something else? Everything works just fine, I'm just wondering what the extra listed process is.
~/ cat test.c
#include <errno.h>
#include <pthread.h>
static pthread_t thread;
void * test_thread(void * ptr)
{
sleep(30);
return(ptr);
}
void thread_init(void)
{
if (pthread_create( &thread , NULL, test_thread, NULL))
perror("Thread not created!");
}
int main(int argc, char ** argv)
{
thread_init();
sleep(30);
}
When I execute this code on a system running Linux 2.6.14 and BusyBox (but using bash 2.04g), the ps
listing I get after rebooting and launching my test program above:
...
52 root SW [kswapd0]
667 root SW [mtdblockd]
710 root SWN [jffs2_gcd_mtd4]
759 root 980 S /bin/sh
760 root 500 S /bin/inetd
761 root 516 S /bin/boa
762 root 644 S /sbin/syslogd -n
763 root 640 S /sbin/klogd -n
766 root 1516 S /bin/sshd -i
767 root 1036 S -sh
768 root 420 S ./test
769 root 420 S ./test
770 root 420 S ./test
771 root 652 R ps
The kernel is a 2.6.14 kernel with a few added drivers modules.