giuliano108 / guix-packages

Guix on WSL2, packages and notes
GNU General Public License v3.0
52 stars 9 forks source link

Can only run one "wsl -d guix" terminal at a time #4

Closed giuliano108 closed 3 years ago

giuliano108 commented 3 years ago

Quoting from Guix-on-WSL2.md:

Can only run one "wsl -d guix" terminal at a time

I don't know why but, after shepherd is started with the recipe above, you can't open another "terminal" (I mean: open cmd.exe, run wsl -d guix --exec /busybox sh. The wsl command returns immediately back to prompt. dmesg contains:

[ 3541.851862] init: (48) ERROR: CreateProcessEntryCommon:600: initgroups failed 29
[ 3541.851865] init: (48) ERROR: CreateProcessEntryCommon:645: Create process not expected to return
giuliano108 commented 3 years ago

I've strace'd init:

# strace -p 1 -s 1024 -f -o /root/init.txt

and got:

223   socket(AF_UNIX, SOCK_STREAM|SOCK_CLOEXEC, 0 <unfinished ...>
223   <... socket resumed>)             = 17
223   connect(17, {sa_family=AF_UNIX, sun_path="/var/run/nscd/socket"}, 24 <unfinished ...>
223   <... connect resumed>)            = 0
223   sendmsg(17, {msg_name=NULL, msg_namelen=0, msg_iov=[{iov_base="<redacted>", iov_len=12}, {iov_base="root\0", iov_len=5}], msg_iovlen=2, msg_controllen=0, msg_flags=0}, MSG_NOSIGNAL <unfinished ...>
223   <... sendmsg resumed>)            = 17
223   readv(17,  <unfinished ...>
223   <... readv resumed>[{iov_base="<redacted>", iov_len=11}, {iov_base="<redacted>", iov_len=1024}], 2) = 24
223   lseek(17, -12, SEEK_CUR <unfinished ...>
223   <... lseek resumed>)              = -1 ESPIPE (Illegal seek)
223   close(17 <unfinished ...>
223   <... close resumed>)              = 0
223   getpid( <unfinished ...>
223   <... getpid resumed>)             = 223
223   writev(3, [{iov_base="<3>init: (223) ERROR: CreateProcessEntryCommon:600: initgroups failed 29\n", iov_len=73}, {iov_base=NULL, iov_len=0}], 2 <unfinished ...>

It looks like Microsoft's /init tries to do something with /var/run/nscd/socket, which results in an ESPIPE error. That's consistent with the initgroups failed 29 message we saw:

$ errno -l  | grep ESPIPE
ESPIPE 29 Illegal seek

Workaround

Stopping nscd makes it possible to open multiple wsl -d guix terminals at the same time

example

This fails right after "booting" the WSL Guix distro with wsl -d guix --exec /busybox sh /root/boot.sh (as Guix-on-WSL2.md suggests you do):

PS C:\Users\Giuliano> wsl.exe -d guix --exec /busybox sh
PS C:\Users\Giuliano>

If, from within Guix, I run:

bash-5.0# herd stop nscd
Service nscd has been stopped.
bash-5.0#

Then i can open a second terminal:

PS C:\Users\Giuliano> wsl.exe -d guix --exec /busybox sh
/mnt/c/Users/Giuliano #