DamionGans / ubuntu-wsl2-systemd-script

[Does not work anymore!] Script to enable systemd support on current Ubuntu WSL2 images
1.56k stars 383 forks source link

Dealing with error: nsenter: failed to parse pid #79

Open galdalali opened 2 years ago

galdalali commented 2 years ago

Weirdest thing ever,

Sometimes, I get this error when trying to run WSL:

nsenter: failed to parse pid: '48
49'

It is defiantly something related to that package (systemd) since it never happened before I install it. Now the way to solve it is to open PowerShell and run wsl --shutdown and then it loads OK.

The weird part is that I'm trying to run it from a bat script and shutdown the WSL every time I run the script using

powershell -Command "& {wsl --shutdown}"
timeout /t 5

or this:

:wsl_stop
for /F "tokens=3 delims=: " %%H in ('sc query "Lxssmanager" ^| findstr "        STATE"') do (
  if /I "%%H" NEQ "STOPPED"  (
   wsl --terminate %DISTRIBUTION%
   timeout /t 1
   sc stop "Lxssmanager"
   goto wsl_stop
  )
)

But the wsl still wont come up, only when I run then wsl --shutdown command manually on PowerShell.

Any thoughts or a way around it?