即使目标线程正在运行,主线程也会在 pthread_join 之后恢复执行
我们在其中一个客户环境中面临着非常奇怪的问题。主线程启动目标 pthread,然后在 pthread_join 处等待。然后我们运行由目标线程处理的流量,但几分钟后我们发现主线程在 pthread_join 之后恢复执行。目标线程尚未完成并且仍在运行。这是在 Solaris9 Sparc 上运行的,我们已经使用 ps -eLf 命令验证了目标线程是否已启动。
如果有人在 Solaris9 Sparc 上的 POSIX 线程中看到过这种行为,可以帮忙吗?
extern "C" void *launchSmtpThread(void *idp)
{
SmtpServerArg *serverArg = (SmtpServerArg*) idp;
int rc = startSmtpServer(serverArg);
cout <<"***********ERRORCODE from SMTP =="<<rc<<endl;
return NULL;
}
-------------------
------------------
int main(int argc, char* argv[])
{
----------------------
----------------------
smtpserverArg.config = &smtpConfig;
smtpserverArg.appAlocFn = &createSmtpApp;
pthread_t tid;
pthread_create(&tid, NULL, launchSmtpThread, (void *)&smtpserverArg);
-----------------
-----------------
//*****************************
//wait on SmtpServer thread
//*****************************
int status;
pthread_join(tid,(void**)&status);
cout<< "exiting main()"<<endl;
}
We are facing very strange issue in one of the customer environment. The Main thread launches a target pthread and then waits at pthread_join. We then run our traffic which is being handled by target thread but after few minutes we find main thread resuming execution after pthread_join. The target thread hasn't finished and is still up and running. This is running on Solaris9 Sparc and we have verified the threads using ps -eLf command that the target thread is up.
Can anyone please help if they have seen such a behavior with POSIX threads on Solaris9 Sparc.
extern "C" void *launchSmtpThread(void *idp)
{
SmtpServerArg *serverArg = (SmtpServerArg*) idp;
int rc = startSmtpServer(serverArg);
cout <<"***********ERRORCODE from SMTP =="<<rc<<endl;
return NULL;
}
-------------------
------------------
int main(int argc, char* argv[])
{
----------------------
----------------------
smtpserverArg.config = &smtpConfig;
smtpserverArg.appAlocFn = &createSmtpApp;
pthread_t tid;
pthread_create(&tid, NULL, launchSmtpThread, (void *)&smtpserverArg);
-----------------
-----------------
//*****************************
//wait on SmtpServer thread
//*****************************
int status;
pthread_join(tid,(void**)&status);
cout<< "exiting main()"<<endl;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论