c - Pthread not executing function -


i have been trying figure out why thread created in c, using pthread library not executing fucntion pthread_create recieves.

here code:

    void* escucharcpus (void* arg){      t_escucha* cpu= (t_escucha*) arg;       listen(cpu->servidor,cpu->cantconexiones);      printf("estoy esperando cpus");      t_cpu* newcpu=malloc(sizeof(t_cpu));      while(1){       int cliente2 = recibircliente(cpu->servidor);       printf("recibí una conexión en %d!!\n", cliente2);       inicializarcpu(newcpu);       list_add(listacpus,newcpu);      }     }     //this function pthread_create recieves.      typedef struct{      int servidor;      int cantconexiones;     }t_escucha;      //this 1 above auxiliar function networking, put info.      //this goes inside main     t_escucha* cpu;     cpu=malloc(sizeof(t_escucha));      //and, here thread creation     pthread_t hiloescuchacpus;     pthread_attr_init(&atributo);     pthread_attr_setdetachstate(&atributo,pthread_create_detached);     t2=pthread_create(&hiloescuchacpus,&atributo,escucharcpus,(void*)cpu);     //is inside main 

the result is, pthread_create acts if hasn't do.

we(my entire working team) dont know going wrong there.

anything propose helpful, thank you!!

to flush stdout (which used printf()) suffix each "string" new-line

   printf("estoy esperando cpus\n"); 

debug logging should go stderr using fprintf(stderr, ...). stderr isn't buffered stdout is.


Comments

Popular posts from this blog

scala - 'wrong top statement declaration' when using slick in IntelliJ -

c# - DevExpress.Wpf.Grid.InfiniteGridSizeException was unhandled -

PySide and Qt Properties: Connecting signals from Python to QML -