I have the following code, and I do ps aux | grep myprogramat each stage of the main () code myprogram (name of the application being created).
At the beginning of the execution of myprogram , it ps aux | grep myprogramshows only 1 time myprogram in the list
after canceling the thread that I created during begging main(), it ps aux | grep myprogramshows myprogram twice , and I expected to get only 1.
Can someone explain this behavior? and how to return to the original 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()
{
pthread_create(&test_thread, NULL, &thread_test_run, NULL);
sleep (20);
pthread_cancel(test_thread);
return 0;
}
EDIT
libc used by linux libc-0.9.30.1.so
-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
source
share