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

Windows processes launched from WSL do not terminate when killed from WSL #2151

Closed
cspotcode opened this issue May 24, 2017 · 3 comments
Closed

Comments

@cspotcode
Copy link

Your Windows build number:

Microsoft Windows [Version 10.0.15063]

What you're doing and what's happening:

# At WSL bash prompt
/mnt/c/Windows/System32/cmd.exe &
sleep 1
# Do one of the following:
kill $!
# ...or
kill -9 $!
# Confirm that Linux cmd.exe process is terminated
ps
# In Windows Task Manager, cmd.exe process is still running

I see the same behavior when running python.exe or notepad.exe.

What's wrong / what should be happening instead:

Starting a Windows command-line process from WSL and then sending SIGTERM, SIGKILL, or pressing Ctrl+C terminates the Linux process but does not terminate the Windows process. I am expecting the Windows process to be terminated. Is the behavior I'm seeing by design or a bug?

@therealkenc
Copy link
Collaborator

therealkenc commented May 24, 2017

Oddly this kind of goes to #2110. FWIW, you can't kill -9 a Windows process in Cygwin/MSYS2 either. Which isn't the least bit surprising; because win32 processes "don't work like that". But it would be academically interesting to see how far the WSL guys want to take this in the hypothetically distant future.

@cspotcode
Copy link
Author

When you launch a Windows process from WSL, you do see a Linux process appear in WSL. And it is different from the process in Windows. (different PIDs) #2110 is talking about how the ps command doesn't list windows processes, but in the situation I'm describing, something does appear in ps output.

Since a Linux process with PID is created (different from the corresponding Windows PID) I would hope that sending SIGTERM to the Linux process would send a corresponding termination request to the Windows process.

Pressing Ctrl+C does terminate the Linux process. I assume this means it's listening for SIGTERM and exiting when it gets it. However, it doesn't send the Windows process a SIGINT signal, WM_CLOSE or WM_QUIT message.

I'm sure I'm oversimplifying, but here's my best guess equivalence between Linux and Windows:

Linux Windows
SIGTERM SIGINT signal for CONSOLE subsystem, WM_CLOSE* message for WINDOWS subsystem
SIGKILL TerminateProcess()

*This post says that TaskKill.exe will send WM_CLOSE when the /F flag is omitted.

@benhillis
Copy link
Member

benhillis commented May 24, 2017

Thanks for posting. This is the same request as #1614. Support for this is on my backlog - marking this thread as a duplicate.

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

3 participants