Expected behavior of an application launched through SSH in two different scenarios

Rohan Pande 445 Reputation points
2024-05-28T15:14:06.4566667+00:00

Hi,

I have a C++ application which can also runs as a Service. I am trying to launch my application on a remote machine from a client machine. For this, I am using the 'Open SSH' software.

Want to understand what is the expected behaviour from the OS if we launch the application in the below scenarios?

Scenarios:

  1. Launching the application normally from the SSH terminal after logging in.
  2. After connecting to the remote machine, I have created the services using 'sc' command and started the service.

Observations:

Regarding 1st :

I have launched the application, it launched in the 'Background Process' of Task Manager. So, it was acting like as non-interactive app. If I close the SSH connection from client machine, the application also gets terminated.

Regarding 2nd:

The application has launched as service. Now, if I close the SSH connection, the application doesn't get terminated and still continues to run.

So, is this as expected behaviour from the OS also?

Developer technologies | C++
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Bruce (SqlWork.com) 78,311 Reputation points Volunteer Moderator
    2024-05-28T16:16:00.62+00:00

    you are correct. the SSH terminal has an associated login session. if you run a terminal command under the session it runs as a session process. if you exit the session all processes exit.

    services are created an run by the NT service worker. it owns the process. so while the sc command itself runs under the SSH session, it messages the service worker to start the service, it does not start the service itself. this is similar to how you would launch a daemon on unix via the launchctl/systemctl command.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.