Oct 24, 2012, 1:42 AM
Post #2 of 2
How do you invoke the "new" script?
Re: [dgalron] How can I pass an open session of Net::SSH2 to a script running in a forked subprocess?
[In reply to]
I have never tried it, but my attempt would be, to execute the new script in the context of the current one, i.e. after the fork(), when you are in the child process, execute the script with require or do. The (global) data of the parent script should then be available in the child.
I must admit that I don't know enough about Net::SSH2 to say for sure that this will work. In particular, I don't know what to do with the Net::SSH2 object you have allocated in the parent script. You certainly should not touch it (and, in particular, make sure that it does not get destructed).