For some reason, pthread_create isn’t allowing me to pass a struct as an argument. The issue is not system related, although I have not had a chance to test it on anyone else’s box. It simply won’t allow me to pass a struct for some reason; it returns error #12.
The issue is not with memory. I know 12 is ENOMEM, and “that should be that”, but it’s not.. it simply won’t accept my struct as a pointer.
struct mystruct info;
info.website = website;
info.file = file;
info.type = type;
info.timez = timez;
for(threadid = 0; threadid < thread_c; threadid++)
{
// printf("Creating #%ld..\n", threadid);
retcode = pthread_create(&threads[threadid], NULL, getstuff, (void *) &info);
//void * getstuff(void *threadid);
When I ran this code in GDB, for some reason, it didn’t return code 12.. but when I run it from the command line, it returns 12.
Any ideas?
Error code 12 on Linux:
You are likely running out of memory. Make sure you’re not allocating too many threads, and be sure to
pthread_jointhreads when they’re done (or usepthread_detach). Make sure you’re not exhausting your memory through other means as well.