Poco AsyncChannel does not exit on forked process exit

435 views Asked by At

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

There are 1 answers

0
ashish behl On BEST ANSWER

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.