1

I am trying to start xrdp from Windows with the method described here, but when I run the command wsl sudo service xrdp start, xrdp doesn't start up properly. Running service xrdp status as my linux user returns

 * could not access PID file for xrdp-sesman
 * xrdp is not running

and I can't connect via RDP. Running wsl -u USER sudo service xrdp start gives me the same result. How can I fix this and run the service properly?

The Bic Pen
  • 145
  • 1
  • 9
  • [I am pretty sure you have skipped some vital required steps.](https://www.nextofwindows.com/how-to-enable-wsl2-ubuntu-gui-and-use-rdp-to-remote). I have in the past followed those instructions without an issue. Try running `sudo /etc/init.d/xrdp status` You should also verify that `xrdp` even exists within `/ect/init.d` – Ramhound Feb 23 '21 at 22:56
  • [You are definitely running the wrong command](https://www.reddit.com/r/linux/comments/ig0cyn/wsl2_gui_setup_using_xrdp_with_additional_tips/). [Even the link question uses the same command syntax](https://superuser.com/questions/1582234/make-ip-address-of-wsl2-static/1619390#1619390) – Ramhound Feb 23 '21 at 23:00
  • @Ramhound running `wsl.exe sudo /etc/init.d/xrdp start` from windows results in `*xrdp-sesman is running` `* xrdp is not running`, and I can't connect to the session. `xrdp` does exist in `/ect/init.d`, and I can run `sudo service xrdp start` from bash just fine. – The Bic Pen Feb 23 '21 at 23:15
  • how can the service be running and not running at the same time? Why did you run those commands within WSL itself, why within Windows? You did make sure to change the port in the xrdp configuration? – Ramhound Feb 23 '21 at 23:21
  • I don't know why checking the status of `xrdp` gives me the status of 2 processes. Maybe both of those processes are necessary for xrdp or something. I did not change the port because it works just fine with the default port. To clarify, when I start the `xrdp` service from bash (in WSL), it works as expected. When I run the command from Windows via `wsl.exe`, it doesn't work. – The Bic Pen Feb 24 '21 at 00:00

1 Answers1

1

The problem is xrdp service init script does not detach stdout before returning and once wsl.exe exits, it closes all pipes which terminates the script.

Straightforward *nix tool for this problem is nohup, but it redirects output to file.

>wsl nohup sudo service xrdp start
nohup: ignoring input and appending output to 'nohup.out'

Somewhat weird workaround I've found is passing command output to cat which prevents premature termination of script and passes output.

wsl bash -c "sudo service xrdp start |cat"

In the end I resorted to a script in the external file. However, it can be written in one line. Fortunately, cmd passes everything to bash in this line.

wsl sudo service xrdp start; until service xrdp status; do sleep 1; done
  • This was the last brick I needed to build my castle. I found 'nohup sudo service xrdp start >>/dev/null' worked for me. – BobHy Oct 21 '21 at 15:45