I want to debug a c++ app on a remote server and I want to open gdbserver via ssh and then close the ssh session immediately while the gdbserver remains open.

ssh  user@xxx.xxx.xxx.x 'cd /remote/bin && gdbserver :3030 ./c++_app'

The above command starts the remote gdbserver but ssh remains open. It gives the correct print out:

Process ./c++_app created; pid = 3967
Listening on port 3030

But it can be closed only by giving ctrl-c or by giving ssh user@xxx.xxx.xxx.x killall gdbserver &> /dev/null via a different ssh terminal.

In order to close the ssh session immediately , I tried the following according to this link (https://unix.stackexchange.com/questions/266571/remotely-starting-a-screen-session-through-ssh-and-closing-the-ssh-session-immed)

ssh user@xxx.xxx.xxx.x  screen -d -m  'cd /remote/bin && gdbserver :3030 ./c++_app'

but unfortunatelly I'm getting :

Process ./c++_app created; pid = 4697
Cannot exec ./c++_app: No such file or directory.

Child exited with status 127
No program to debug

I also tried with double quotes :

   ssh user@xxx.xxx.xxx.x  screen -d -m  "cd /remote/bin && gdbserver :3030 ./c++_app"

But got the same error as before.
What I'm doing wrong here ?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.