Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remote invoke of START from BAT kills STARTed process #1195

Open
DerekBennett opened this issue Jun 21, 2018 · 11 comments
Open

Remote invoke of START from BAT kills STARTed process #1195

DerekBennett opened this issue Jun 21, 2018 · 11 comments

Comments

@DerekBennett
Copy link

DerekBennett commented Jun 21, 2018

"OpenSSH for Windows" version
This version command did not work for me. The SSH installation I used is the current release: "OpenSSH-Win64-v7.7.0.0p1-Beta"

Server OperatingSystem
Windows Server 2012 R2 Standard

Client OperatingSystem
Windows Server 2012 R2 Standard

What is failing
I am using OpenSSH-Win64-v7.7.0.0p1-Beta to invoke a BAT file remotely. The BAT file sets some environment variables and then calls START "" someprogram.exe. This used to work just fine in prior releases of SSH. Now, however, START no longer works. Instead the someprogram.exe instance dies as soon as the BAT file exits.

Expected output
I expect the STARTed process to detach and continue running as a parentless process.

Actual output
The STARTed process exits as soon as the BAT file that STARTed it exits.

This issue refers to #1032

@maertendMSFT
Copy link
Collaborator

maertendMSFT commented Apr 21, 2020

By design we associate the job object with the initial process, so that all the child processes are cleaned-up automatically. This is the same behavior as Linux.

Look for a work-around: #1032

@DerekBennett
Copy link
Author

@manojampalam asked me on #1032 to create a new issue, this one. As far as I am aware. The problem I reported is still a problem. The behavior in *nix is that you can execute a remote command that outlives the ssh session. We want the same behavior in Windows. Use a BAT file to set some environment variables and command-line switches, and then run a daemon process that continues without problem after the ssh session goes away.
This issue or #1032 should remain open. Additionally, I do not see a work-around in #1032. If there is one, please write something about the workaround in the documentation.

@bagajjal
Copy link
Collaborator

Reopening the issue. I will try to reproduce tomorrow.

@bagajjal bagajjal reopened this Apr 22, 2020
@valeriob
Copy link

valeriob commented Jun 7, 2021

Hi,
i'm facing the same issue, porting some code from linux to windows, i'm unable to find the same behaviour as nohup :( I tested 8.1 and 8.6.
Anybody found a workaround ?

@bagajjal
Copy link
Collaborator

bagajjal commented Jun 7, 2021

@DerekBennett , @valeriob - Have you tried this #1032 (comment)?

By default all the processes launched by SSH are closed once the SSH session is closed. If you want the process to execute independent of ssh session then you need to try spawn your process with special flags as mentioned in the above link.

@DerekBennett
Copy link
Author

@DerekBennett , @valeriob - Have you tried this [#1032 (comment)]
No. That solution looks unsustainable. It would be better if SSH would invoke processes with the special flags by default. SSH should have the exact same spawning behavior on all platforms.

@bagajjal
Copy link
Collaborator

bagajjal commented Jun 7, 2021

@DerekBennett - It's same behavior on *nix systems as well.
Any process launched within ssh session is tied to that session. In *nix systems, users use screen / tmux to achieve this.

@valeriob
Copy link

valeriob commented Jun 7, 2021

Hi,
i'm currently using cmd, the powershell solution is very obscure and it raises the bar of the requirements (WMI and powershell), if openssh has the same behavior in windows and linux, what would be the nohup equivalent ?

@bagajjal
Copy link
Collaborator

bagajjal commented Jun 7, 2021

@valeriob - You need to create process with special flags as mentioned here #1032 (comment)

@vborioni-onit
Copy link

Hi,
i've done it like suggested, it's not a very nice solution, and it forces to use powershell, i really wish there was a simple tool like nohup.

@bagajjal
Copy link
Collaborator

bagajjal commented Jun 8, 2021

@vborioni-onit - Unfortunately windows OS doesn't have nohup, screen, tmux. All these utilities are out of scope of this project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants