为什么pthread_create()返回12?

Sau*_*tin 1 c pthreads

出于某种原因,pthread_create不允许我传递一个struct作为参数.这个问题与系统无关,虽然我没有机会在其他任何人的盒子上测试它.struct由于某种原因,它根本不允许我通过; 它返回错误#12.

问题不在于记忆.我知道12是ENOMEM,"那应该是那个",但它不是......它根本不会接受我的结构作为指针.

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);
Run Code Online (Sandbox Code Playgroud)

当我在GDB中运行此代码时,出于某种原因,它没有返回代码12 ..但是当我从命令行运行它时,它返回12.

有任何想法吗?

bdo*_*lan 7

Linux上的错误代码12:

#define ENOMEM          12      /* Out of memory */
Run Code Online (Sandbox Code Playgroud)

你可能内存不足.确保你没有分配太多的线程,并确保pthread_join线程完成(或使用pthread_detach).确保你不会通过其他方式耗尽记忆力.