我有一个线程来接受传入连接:
pthread_t thread;
pthread_create(&thread, NULL, worker_func, NULL);
pthread_detach(thread);
Run Code Online (Sandbox Code Playgroud)
然后worker_func:
<snip>
fd = accept(GlobalFD, NULL, NULL);
<snip>
Run Code Online (Sandbox Code Playgroud)
但是,如果我尝试GlobalFD在原始线程中关闭,accept 仍会阻塞(如果 GlobalFD 关闭,我希望它失败)。我在网上查看了其他问题,但似乎找不到我的特定问题的答案。
有任何想法吗?谢谢