Why does the process/task triggered on the VM gets stopped when the SSH connection used to create the process was broken?

1

I have a VM running on some remote host. I do connect to it from my desktop PC over SSH through putty. I trigger a build process on that VM.

Now if i close the putty SSH session, why does the build process stops and the image does not get created?

However, if i spin off a VNC server instance on the VM and connect to it through VNC viewer from my desktop PC. Now i could access the VM's GUI environment. Now i launch a terminal. And start a build process.

Now even if i close the VNC client or shutdown my desktop PC, still the build process be happening.

How are they different in each of the scenario?

Darshan L

Posted 2018-03-27T13:17:38.963

Reputation: 555

Answers

2

Why is the process killed? When you connect, your default bash gets started. Now as you start a process, they are sub process of bash. If the connection gets closed, bash and all it's sub processes are being terminated.


Solution: use screen. Run screen and start your build process. If you have a disconnect, everything run after screen will continue. If you reconnect by ssh now, and run screen -RD, you will get back to your session and see the process.


VNC only relays the screen and the control of mouse/keyboard to your system. All processes run like it would, if you were sitting in front of that system.

davidbaumann

Posted 2018-03-27T13:17:38.963

Reputation: 2 089

VNC servers can work both ways; on Linux it is common for them to have their own sessions (like RDP on Windows). But the question, I believe, was why "bash and all its subprocesses" get terminated in the first place with SSH? – user1686 – 2018-03-27T13:33:12.070

@grawity Because they are subprocesses of the SSH child which gets terminated? – davidgo – 2018-03-27T18:09:59.337