即使目标线程正在运行,主线程也会在 pthread_join 之后恢复执行

发布于 2024-12-28 10:48:51 字数 1076 浏览 5 评论 0原文

我们在其中一个客户环境中面临着非常奇怪的问题。主线程启动目标 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文