pthread_create and EAGAIN

前端 未结 5 872
独厮守ぢ
独厮守ぢ 2021-01-18 18:13

I got an EAGAIN when trying to spawn a thread using pthread_create. However, from what I\'ve checked, the threads seem to have been terminated properly.

What determi

5条回答
  •  太阳男子
    2021-01-18 18:42

    Okay, found the answer. Even if pthread_exit or pthread_cancel is called, the parent process still need to call pthread_join to release the pthread ID, which will then become recyclable.

    Putting a pthread_join(tid, NULL) in the end did the trick.

    edit (was not waitpid, but rather pthread_join)

提交回复
热议问题