How can I pass an open session of Net::SSH2 to a script running in a forked subprocess?

Can't Post

I have a test script, which opens a session using Net::SSH2. After new,connect,auth...,channel,blocking(0) and shell the script reads and writes. Now I need to fork and run another script in the child process. This script should continue the dialog using already established session. The problem is: I have no idea how to pass this open session to the new script. Thanks in advance.

Re: [dgalron] How can I pass an open session of Net::SSH2 to a script running in a forked subprocess?
[In reply to]

Can't Post

How do you invoke the "new" script?

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).