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
  • 165
  • 1
  • 9

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