arkane-systems / genie

A quick way into a systemd "bottle" for WSL
Other
1.85k stars 104 forks source link

systemd keeps running after exiting the wsl distro. #245

Closed akuropka closed 2 years ago

akuropka commented 2 years ago

Windows version (build number): 10.0.22572.100

Linux distribution: Arch Linux using wsldl.

Genie version: genie 2.0 (as per genie --version) genie 42e1d851b333a8292c4f84aba8e87eda3891f305 (actually built version)

Describe the bug With genie initialized and running as shell (genie -s) after exiting the session with exit the shell window keeps open and does not close automatically.

Confirm that you are running inside the bottle: inside

Command used during starting the shell session (e.g. .bash_profile):

# Start genie
if [[ ! -v INSIDE_GENIE ]]; then
  exec /usr/bin/genie -s
fi

To Reproduce Steps to reproduce the behavior:

  1. Add above code to .bash_profile.
  2. For safety's sake shut down wsl (wsl --shutdown).
  3. Open a new shell.
  4. exit the shell.

Expected behavior The shell window closes.

Screenshots 20220314_115539_wslhost

I confirm that I have read the ENTIRE supplied readme file and checked for relevant information on the repository wiki before raising this issue, and that if the solution to this issue is found in either location, it will be closed without further comment:

cerebrate commented 2 years ago

Haven't had any luck reproing this so far, alas.

A couple of questions, though --

akuropka commented 2 years ago

@cerebrate, thank you for your reply. Please see the screencast, maybe you have an idea... it's only after running genie.

https://user-images.githubusercontent.com/22570574/159068907-f38575a9-3514-46d3-8d7d-9217dbd61bc2.mp4

cerebrate commented 2 years ago

Huh. That is very strange.

My best speculation here is that there has to be some leftover process in the session keeping the pty alive and so holding the window open. So I've got to ask you for three more things:

Hopefully that'll give us a clue as to what it might be.

akuropka commented 2 years ago

ps aux before entering the bottle:

USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root         1  0.1  0.0   2020  1280 ?        Sl   18:32   0:00 /init
root        14  0.0  0.0   2028    96 ?        Ss   18:32   0:00 /init
root        15  0.1  0.0   2028   104 ?        S    18:32   0:00 /init
andi        16  0.2  0.0   8604  5228 pts/0    Ss   18:32   0:00 -bash
andi       131  0.0  0.0  10220  3356 pts/0    R+   18:32   0:00 ps aux

systemctl status inside bottle:

● ANDI-wsl
    State: running
     Jobs: 0 queued
   Failed: 0 units
    Since: Sat 2022-03-19 18:32:15 CET; 7s ago
   CGroup: /

ps aux after exiting the bottle:

USER         PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root           1  0.0  0.0   2020  1280 ?        Sl   18:32   0:00 /init
root          14  0.0  0.0   2028    96 ?        Ss   18:32   0:00 /init
root          15  0.1  0.0   2028   104 ?        S    18:32   0:00 /init
andi          16  0.1  0.0   8604  5292 pts/0    Ss   18:32   0:00 -bash
root         140  0.0  0.0   5640  1028 ?        Ss   18:32   0:00 /usr/sbin/unshare -fp --propagation shared --mount-proc -- systemd
root         141  2.2  0.0  21676 11560 ?        Ss   18:32   0:00 systemd
root         168  3.6  0.1  56660 29268 ?        Ss   18:32   0:00 /usr/lib/systemd/systemd-journald
root         177  0.7  0.0  27252  8252 ?        Ss   18:32   0:00 /usr/lib/systemd/systemd-udevd
dbus         201  0.1  0.0   8596  4884 ?        Ss   18:32   0:00 /usr/bin/dbus-daemon --system --address=systemd: --nofork --nopidfile --systemd-activation --syslog-only
root         202  0.2  0.0  15736  7648 ?        Ss   18:32   0:00 /usr/lib/systemd/systemd-logind
root         204  0.0  0.0   5656  1048 hvc0     Ss+  18:32   0:00 /sbin/agetty -o -p -- \u --keep-baud 115200,57600,38400,9600 - vt220
root         208  0.0  0.0  15448  7416 ?        Ss   18:32   0:00 /usr/lib/systemd/systemd-machined
andi         214  0.3  0.0  17484 10144 ?        Ss   18:32   0:00 /usr/lib/systemd/systemd --user
andi         215  0.0  0.0  25128  2880 ?        S    18:32   0:00 (sd-pam)
andi         345  0.0  0.0  10220  3436 pts/0    R+   18:32   0:00 ps aux

If I kill systemd and exit the shell afterwards the window closes. For reference: journal.txt

Using genie --shutdown after exiting the bottle closes all processes but brings up the following error:

Traceback (most recent call last):
  File "/usr/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/usr/lib/genie/genie/__main__.py", line 904, in <module>
  File "/usr/lib/genie/genie/__main__.py", line 895, in entrypoint
  File "/usr/lib/genie/genie/__main__.py", line 800, in do_shutdown
  File "/usr/lib/genie/genie/__main__.py", line 270, in hostname_restore
  File "/usr/lib/python3.10/subprocess.py", line 501, in run
    with Popen(*popenargs, **kwargs) as process:
  File "/usr/lib/python3.10/subprocess.py", line 966, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/usr/lib/python3.10/subprocess.py", line 1842, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'hostname'
akuropka commented 2 years ago

I'm closing this as it seems the issue cannot be resolved. In addition I moved to a different solution.