I have the following code and I make ps aux | grep myprogram
in each step of the main() code of myprogram (name of the application I build).
At the beggining of the execution of myprogram, the ps aux | grep myprogram
show only 1 time the myprogram in the list
after cancelling a thread that I created in the begging of the main()
, the ps aux | grep myprogram
show the myprogram twice and I expected to get only 1.
Could some one explain this behaviour? and how to return to the initial situation (only 1 myprogram)
#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
pthread_t test_thread;
void *thread_test_run (void *v)
{
int i=1;
while(1)
{
printf("into thread %d\r\n",i);
i++;
sleep(1);
}
return NULL
}
int main()
{
// ps aux | grep myprogram ---> show only 1 myprogram
pthread_create(&test_thread, NULL, &thread_test_run, NULL);
// ps aux | grep myprogram ---> show 3 myprogram
sleep (20);
pthread_cancel(test_thread);
// ps aux | grep myprogram ---> show 2 myprogram and I expected only 1 !!??
// other function are called here...
return 0;
}
EDIT
the libc used by the linux is libc-0.9.30.1.so
# ls -l /lib/| grep libc
-rwxr-xr-x 1 root root 16390 Jul 11 14:04 ld-uClibc-0.9.30.1.so
lrwxrwxrwx 1 root root 21 Jul 30 10:16 ld-uClibc.so.0 -> ld-uClibc-0.9.30.1.so
lrwxrwxrwx 1 root root 21 Jul 30 10:16 libc.so.0 -> libuClibc-0.9.30.1.so
-rw-r--r-- 1 root root 8218 Jul 11 14:04 libcrypt-0.9.30.1.so
lrwxrwxrwx 1 root root 20 Jul 30 10:16 libcrypt.so.0 -> libcrypt-0.9.30.1.so
-rw-r--r-- 1 root root 291983 Jul 11 14:04 libuClibc-0.9.30.1.so