简体   繁体   English

Poco AsyncChannel不会在派生进程退出时退出

[英]Poco AsyncChannel does not exit on forked process exit

Problem: 问题:

Call/Initialize Poco code from inside a C library, using loader (3rd party C program, our code is in c++). 使用加载程序(第三方C程序,我们的代码在c ++中)从C库内部调用/初始化Poco代码。

  1. The Program loads our library, our lib initializes Poco::Logger and uses AsyncChannel + FileChannel in the logger. 该程序加载我们的库,我们的lib初始化Poco :: Logger并在记录器中使用AsyncChannel + FileChannel。
  2. Fork from this process. 从这个过程叉。
  3. Run some threads in the child process. 在子进程中运行一些线程。
  4. try to exit the child process, joining threads. 尝试退出子进程,加入线程。
  5. The AsyncChannel's destructor blocks on close(), essentially polling Queue and sleeping. AsyncChannel的析构函数在close()上阻塞,实质上是轮询Queue和sleeping。
  6. The _queue has 1 element always when the destructor for AsyncChannel is called, and I assume that is due to the way the parent process is running and forking. _queue总是在调用AsyncChannel的析构函数时具有1个元素,我认为这是由于父进程的运行和派生方式引起的。

Now the question: Is this a problem with gcc that Forking a process does not call the constructors and just duplicates the memory? 现在的问题是:这是gcc的问题,即分叉进程不调用构造函数而只是复制内存吗? I have tried calling _queue.clear() inside AsyncChannel::AsyncChannel() but no results... 我尝试在AsyncChannel :: AsyncChannel()内部调用_queue.clear()但没有结果...

Has anyone seen this problem before? 有人看过这个问题吗? any proposed solution? 有什么建议的解决方案吗?

Response here: 在这里回应:

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

Summary: create threads after fork and not before. 摘要:在fork之后而不是之前创建线程。 Same problem with Poco::Util::Timer and other classes also. Poco :: Util :: Timer和其他类的问题也相同。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM