in reply to daemonizing and threads

I played with Thread::Pool, and seems fine. What I did is:
  1. fork a new process
  2. exit the main process
  3. in the forked process, initialize Thread::Pool
  4. the forked process start an endless loop to dispatch jobs to thread pool. The job my threads do is simple, just take two numbers, and return the sum.
Two points:
  1. It sounds to me more logical to fork first, and then initialize the Thread::Pool, indeed the Thread::Pool object has nothing to do with the main process, from the design view, it should be contained in a smaller as possible scope.
  2. The error msg you got saying exit when other threads running, is because you exited main process, without first stop or join all threads.

Replies are listed 'Best First'.
Re: Re: daemonizing and threads
by Anonymous Monk on Dec 03, 2002 at 16:06 UTC
    I totally agree that one would almost always fork before threading. I had only reversed it for testing.

    As for the error message, I assumed that it was result of the main process exiting. After you pointed that out, I thought about it though... The main process /should/ be dead before the threads even start. Since that does not appear to be the case, would that imply that indeed the original parent is exiting late, perhaps before the child has acheived independence?

    Thanks much for the input.

    mike