Poco AsyncChannel does not exit on forked process exit

馋奶兔 提交于 2019-12-12 04:53:45

问题


Problem:

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

  1. The Program loads our library, our lib initializes Poco::Logger and uses AsyncChannel + FileChannel in the logger.
  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.
  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.

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?


回答1:


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.



来源:https://stackoverflow.com/questions/26998019/poco-asyncchannel-does-not-exit-on-forked-process-exit

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!