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

nohup process terminates when terminal disconnects from ssh session #17999

Open
siddhsql opened this issue Oct 5, 2024 · 5 comments
Open

nohup process terminates when terminal disconnects from ssh session #17999

siddhsql opened this issue Oct 5, 2024 · 5 comments
Labels
Issue-Bug It either shouldn't be doing this or needs an investigation. Needs-Repro We can't figure out how to make this happen. Please help find a simplified repro. Needs-Tag-Fix Doesn't match tag requirements Product-Terminal The new Windows Terminal.
Milestone

Comments

@siddhsql
Copy link

siddhsql commented Oct 5, 2024

Windows Terminal version

1.20.11781.0

Windows build number

10.0.22631.4169

Other Software

No response

Steps to reproduce

  1. ssh to a remote machine from the Windows terminal
  2. run a program (e.g., a node process that spins up a server listening to connections) like nohup npm run &

leave terminal connected. after some period of inactivity (could be few hours) terminal will disconnect (broken pipe) as machine could go to sleep etc.

When this happens the program you started on the remote machine also terminates.

Expected Behavior

program you started on the remote machine should keep running.

Actual Behavior

program you started on the remote machine terminates. Note this does not happen if you exit from the ssh session by typing the exit command vs. leaving the terminal connected and it disconnects due to inactivity. if it helps, on Mac (with iTerm), the problem does not happen when leaving the terminal connected and it disconnects due to inactivity

@siddhsql siddhsql added Issue-Bug It either shouldn't be doing this or needs an investigation. Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting labels Oct 5, 2024
@DHowett
Copy link
Member

DHowett commented Oct 5, 2024

Are you using ssh from within WSL, or the native Windows build of ssh?

@siddhsql
Copy link
Author

siddhsql commented Oct 5, 2024

I have tried both.

  1. ssh from Windows (no WSL)
  2. ssh from WSL using /usr/bin/ssh

@lhecker
Copy link
Member

lhecker commented Oct 7, 2024

I just tried this with my own Linux server from Windows 11 24H2. After disconnecting the network, the process kept running in the background while SSH had exited.

What I suspect is happening is that your server is receiving a signal other than SIGHUP. nohup only catches that one signal and any other signal will still cause node to exit.

As an immediate workaround, I'd suggest either changing your command to npm run &; disown or to use a multiplexer like tmux or zellij. With tmux for instance, you first launch it by running tmux, then you execute your command npm run. No matter what happens now, that tmux and npm instance will keep running forever. You can explicitly detach from it by pressing Ctrl+B, D. You can reattach again by running tmux attach. zellij works similar but is a lot more beginner friendly.

@siddhsql
Copy link
Author

siddhsql commented Oct 7, 2024

Thanks Leonard. re: this:

After disconnecting the network, the process kept running in the background while SSH had exited.

could you be specific how you disconnected from the network? If I disconnect by explicitly exiting from the ssh session using the exit command, the process does keep running. I encounter the issue when the session terminates/disconnects because of prolonged inactivity (Broken Pipe). Did you repro that?

@lhecker
Copy link
Member

lhecker commented Oct 9, 2024

I disabled the network adapter. I hoped that this would be similar to what you experienced.

@carlos-zamora carlos-zamora added Needs-Repro We can't figure out how to make this happen. Please help find a simplified repro. Product-Terminal The new Windows Terminal. and removed Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting labels Oct 9, 2024
@carlos-zamora carlos-zamora added this to the Backlog milestone Oct 9, 2024
@microsoft-github-policy-service microsoft-github-policy-service bot added the Needs-Tag-Fix Doesn't match tag requirements label Oct 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue-Bug It either shouldn't be doing this or needs an investigation. Needs-Repro We can't figure out how to make this happen. Please help find a simplified repro. Needs-Tag-Fix Doesn't match tag requirements Product-Terminal The new Windows Terminal.
Projects
None yet
Development

No branches or pull requests

4 participants