Poco AsyncChannel不会在派生进程退出时退出 [英] Poco AsyncChannel does not exit on forked process exit

查看:203
本文介绍了Poco AsyncChannel不会在派生进程退出时退出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问题:

使用加载程序(第三方C程序,我们的代码在c ++中)从C库内部调用/初始化Poco代码.

Call/Initialize Poco code from inside a C library, using loader (3rd party C program, our code is in c++).

  1. 程序加载我们的库,我们的lib初始化Poco :: Logger并在记录器中使用AsyncChannel + FileChannel.
  2. 此过程中的叉子.
  3. 在子进程中运行一些线程.
  4. 尝试退出子进程,加入线程.
  5. AsyncChannel的析构函数在close()上阻塞,实质上是轮询Queue并进入睡眠状态.
  6. 在调用AsyncChannel的析构函数时,_queue始终具有1个元素,我认为这是由于父进程的运行和派生方式造成的.

现在是一个问题:这是gcc的问题吗,Forking进程不调用构造函数,而只是复制内存? 我尝试在AsyncChannel :: AsyncChannel()内部调用_queue.clear(),但没有结果...

Now the question: Is this a problem with gcc that Forking a process does not call the constructors and just duplicates the memory? I have tried calling _queue.clear() inside AsyncChannel::AsyncChannel() but no results...

以前有没有人看过这个问题?有什么建议的解决方案吗?

Has anyone seen this problem before? any proposed solution?

推荐答案

在此处回复:

http://pocoproject.org/forum/viewtopic.php?f=10& ; t = 6378

摘要:在fork之后而不是之前创建线程. Poco :: Util :: Timer和其他类也有同样的问题.

Response here:

http://pocoproject.org/forum/viewtopic.php?f=10&t=6378

Summary: create threads after fork and not before. Same problem with Poco::Util::Timer and other classes also.

这篇关于Poco AsyncChannel不会在派生进程退出时退出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆