-
Notifications
You must be signed in to change notification settings - Fork 781
Allow Breakaway OK on SSH Job #1032
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
Comments
This is intentional to keep the implementation in line with how it works on Unix. |
@manojampalam thanks for the update, we will have to see what our other options are. In regards to keeping things how they work on Unix, I'm not 100% confident as to how it all works but you can easily run a process "outside" of the SSH shell. For example I can run
Once I exit from the SSH session, the process is still running in the background and the SSH tty no longer exists when running IMO task scheduler is a massive pain when it comes to things like this as;
Ultimately if that is what we need to do then that's what we need to do but I'm hoping to avoid it if possible :) |
@manojampalam Agree 100% with @jborean93 - the job handling is a fine way to deal with cleaning up after a session closes, but processes that explicitly request breakaway should be allowed to do so (ala nohup on POSIX systems). |
Thanks for following up and apologies for a misunderstanding of the original ask. Attached a private if you want to try out. |
Fantastic, I just tried it out locally and it works as you say, it even fixed another issue where we were creating some jobs, looking forward to the release. |
PowerShell/Win32-OpenSSH#1032 Issue: Ssh-shellhost.exe creates a job object and ties all its child processes to its lifetime. It does not allow the child processes to break away from this job. This restriction is unnecessary. Fix: Modified job object to allow child processes to break away if they need to.
Hi! I am using Win32-OpenSSH and have read this issue searching a solution to the process killing when the ssh connection is closed. According to the release notes version v7.6.0.0p1-Beta let applications break away from ssh session. I am using version v7.6.1.0p1-Beta 64 bits version but I can not launch processes in background and they don't continue working when the ssh session is closed. What is the way to achieve this? Thanks in advance! |
@RDCH106, we currently achieve this through some P/Invoke calls in PoweShell and call the CreateProcess Win32 API with a specific flag. This isn't something simple to do and requires a bit of code to achieve but the easiest way I know of to do this in PowerShell is to use WMI. Here is an example script that uses Win32_Process as sets the CREATE_BREAKAWAY_FROM_JOB flag when creating the process
|
@jborean93 Thanks for your answer! |
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. Is this a bug, or should I be doing something differently? |
@DerekBennett can you please open a new issue and add a reference to this thread? |
done
…On Thu, Jun 21, 2018 at 12:01 PM Manoj Ampalam ***@***.***> wrote:
@DerekBennett <https://github.com/DerekBennett> can you please open a new
issue and add a reference to this thread?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1032 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABz_P9sEOjKl_UPLf2Jm7KIKnFsJ-Xvoks5t-8NugaJpZM4RpQiq>
.
--
Derek Bennett
[email protected]
1.917.968.8982
|
"OpenSSH for Windows" version
1.0.0.0
Server OperatingSystem
Windows Server 2016 Standard Evaluation
Still applies to all other hosts as well
Client OperatingSystem
N/A (tested on MacOS though)
What is failing
The
ssh-shellhost.exe
process that is spawned on an SSH connection does not allow processes to breakaway from the job. This means any process it spawns won't be able to breakaway from the SSH job. This is useful if you want to run a process while not keeping the SSH connection open.As you can see by Process Explorer, the only limit placed on the Job is
Kill on Job Close
Compared to a process that is spawned by WinRM, it contains some more job limits that are mostly configurable by the service. The key one I am looking for is
Breakaway OK
which allows the process to call theCreateProcess
(and derivative) theCREATE_BREAKAWAY_FROM_JOB
creation flag https://msdn.microsoft.com/en-us/library/windows/desktop/ms684863(v=vs.85).aspx. You can see this based on the cmd.exe process that I spawned on a WinRM processI'm not sure if this is intentional on your part but it would be good to hear your thoughts on this as this is a key feature Ansible uses to achieve async support on the current WinRM connection. If we were to loose this feature, our options are limited and we may need to resort to scheduled tasks which aren't really that easy to manage.
On a side note this is not a "regression" of the 1.0.0.0 release as this has been the case for the past few releases.
The text was updated successfully, but these errors were encountered: