Situation absolument étrange lors de la création d'un thread, voici le code de test :
#include <stdint.h> /* C99 types */
#include <stdbool.h> /* bool type */
#include <stdio.h> /* printf, fprintf, snprintf, fopen, fputs */
#include <string.h> /* memset */
#include <signal.h> /* sigaction */
#include <time.h> /* time, clock_gettime, strftime, gmtime */
#include <sys/time.h> /* timeval */
#include <unistd.h> /* getopt, access */
#include <stdlib.h> /* atoi, exit */
#include <errno.h> /* error messages */
#include <math.h> /* modf */
#include <assert.h>
#include <sys/socket.h> /* socket specific definitions */
#include <netinet/in.h> /* INET constants and stuff */
#include <arpa/inet.h> /* IP address conversion stuff */
#include <netdb.h> /* gai_strerror */
#include <pthread.h>
void thread_up(void) {
printf("thread ....\n");
int loop=0;
while(loop<=7)
{
printf("loop...\n");
sleep(10);
loop++;
}
printf("Exit loop\n");
}
int main()
{
pthread_t thrid_up=0;
int i = pthread_create( &thrid_up, NULL, (void * (*)(void *))thread_up, NULL);
if (i != 0) {
printf("ERROR: [main] impossible to create upstream thread\n");
exit(1);
}
while(1)
{
sleep(10);
}
}
ce code produit la sortie suivante sur la commande ps (après le lancement de ./test&) :
30214 root 704 S ./test
30215 root 704 S ./test
30216 root 704 S ./test
Un indice ?