I am calling ssh (OpenSSH) from a OSX/Linux-C++-Application via fork/exec to create a dynamic port forwarding. This is done using batch mode (-o BatchMode=yes) and a private key which is supplied to ssh (-i Option). The SSH call itself does not open a shell (-N Option).
This is my full SSH-Call:
ssh -N -D 9000 -o BatchMode=yes -i /path/to/private-key user@host
I would like to proceed with my application as soon as I can and so I have to find out if ssh succeeded creating the channel. SSH itself only returns if it has a problem.
Is there a possibility how I can detect a successful port forwarding?
Of course I can wait until the port is opened by SSH but I am looking for a more elegant solution. Another solution is to inspect SSH's Log (-v) waiting for "Entering interactive Session" but this sounds not very portable to me.