Hi Jonathan, It would be very difficult to share multi-threaded zk handle with child process. I'm surprised it actually works on mac. I think saving session id/password and re-establishing the session in the child process is more robust and platform independent.
Thanks! --Michi On Thu, May 10, 2012 at 12:45 PM, Jonathan Simms <[email protected]> wrote: > Hi all, > > I'm the maintainer of the ruby zookeeper library, and I'm having > trouble getting consistent behavior when a user calls fork(). When > developing it on MacOS (using 3.3.5), I was able to fork, then > immediately call zookeeper_close() in the child, and then create a new > handle. Testing on Linux, the behavior is much more unpredictable. > Regularly, it seems there are segfaults when calling zookeeper_close. > https://gist.github.com/22338464cd47e0e50970 > > > So I guess my question is, is there any safe way to fork() while the > client is running? > > Another possibility i thought of is to note the session id/passwd, > close the client, fork, then re-open with the same id/passwd to > re-establish the session in the parent. > > Any recommendations?
