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

running Windows process from the background opens a new terminal window in WSL preview #7568

Closed
1 of 2 tasks
sakai135 opened this issue Oct 19, 2021 · 9 comments
Closed
1 of 2 tasks

Comments

@sakai135
Copy link

Version

Microsoft Windows [Version 10.0.22478.1012]

WSL Version

  • WSL 2
  • WSL 1

Kernel Version

5.10.60.1

Distro Version

Ubuntu 20.04

Other Software

WSL version: 0.48.2.0

Repro Steps

Run the following command:

wsl.exe start-stop-daemon --background --exec /mnt/c/WINDOWS/system32/ping.exe --start -- -t example.com

Expected Behavior

I expect ping.exe to run in the background without opening a cmd window like in the current (non-preview) WSL.

Actual Behavior

With WSL preview (0.48.2.0), the command opens a new terminal for ping.exe.

Diagnostic Logs

No response

@Biswa96
Copy link

Biswa96 commented Oct 19, 2021

Does this happen using system's WSL after uninstalling the preview one?

@sakai135
Copy link
Author

@Biswa96 I've installed/uninstalled the preview a few times to verify that this only happens with the preview (0.48.2.0).

@OneBlue
Copy link
Collaborator

OneBlue commented Oct 19, 2021

Thanks for reporting this @sakai135.

Where is wsl.exe starting from in this context ? Can you share screenshots ?

@sakai135
Copy link
Author

sakai135 commented Oct 19, 2021

@OneBlue The behavior is the same running the command in Windows PowerShell or the Bash shell in WSL 2 Ubuntu.

image

With the non-preview WSL, the terminal window for ping.exe will not open.

@sakai135
Copy link
Author

Just to update that this is still an issue with the new update:

WSL version: 0.50.2.0
Kernel version: 5.10.74.3
WSLg version: 1.0.29
Windows version: 10.0.22499.1010

@allusernamestakenexceptthis

I have the same issue with same versions. except in my case I experienced by running shell_exec commands from php running in wsl to run an exe file . and it led to a wsl terminal to open. doesn't happen with shell commands only windows commands. such as cmd.exe route.exe ..etc running the same commands from inside an opened wsl terminal doesn't open new one. only from the background.

I tried to put the script inside a .sh file and run the sh file from php. but same results.

I can confirm that I didn't experience the problem before preview from the store. but my kernel was very outdated and custom.

@Vulp-OS
Copy link

Vulp-OS commented Jan 26, 2022

Since this issue still hasn't seen any interaction from MS, I'd like to indicate that this issue still persists on the newest build of Windows 11 when using the WSL Preview from the Microsoft Store.

WSL version: 0.51.2.0
Kernel version: 5.10.81.1
WSLg version: 1.0.30
Windows version: 10.0.22538.1010

@OneBlue
Copy link
Collaborator

OneBlue commented Feb 8, 2022

@sakai135 I had a deeper look and I could reproduce the problem.

This situation this is basically a race between the time the 'ping.exe' process is created and the wsl 'process group' being terminated.
When a Windows process is created, if the 'wsl.exe' that created the session is still running, then this process creates the Windows process.

If this 'wsl.exe' has terminated, then the process is created by wslhost.exe, which isn't attached to the console, which is why ping.exe creates a window as you reported.

So if you do:

$ wsl.exe start-stop-daemon [...]

wsl.exe might terminate before the process actually starts on the Windows side. If you do:

$ wsl.exe
[wsl] $ start-stop-daemon [...]

Then the issue doesn't apply because the wsl process group doesn't terminate.

I need to give some thoughts to this, I'll update this issue when I'll have a solution in mind.

Copy link
Contributor

This issue has been automatically closed since it has not had any activity for the past year. If you're still experiencing this issue please re-file this as a new issue or feature request.

Thank you!

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

No branches or pull requests

5 participants