kovidgoyal / kitty

Cross-platform, fast, feature-rich, GPU based terminal
https://sw.kovidgoyal.net/kitty/
GNU General Public License v3.0
24.41k stars 980 forks source link

When task is killed by system - it kills whole terminal #7427

Closed palandovalex closed 5 months ago

palandovalex commented 5 months ago

Describe the bug

When I run a program in the terminal that eats memory like it's not in itself, it provokes an OOM killer. If such a program is run through gnome terminal, then the result is a "killed" record, but the performance of the terminal itself is not impaired. But when I use kitty, at the moment of killing the program by oom killer, kitty is also killed.

To Reproduce

  1. make programm, that will provoke OOM killer, such as:

infi_array = [] while True: infi_array.append(1)

2. run this programm in kitty.
`python3 oom_provocateur.py`

**Environment details**

kitty 0.32.2 created by Kovid Goyal Linux user-BOD-WXX9 6.8.0-31-generic #31-Ubuntu SMP PREEMPT_DYNAMIC Sat Apr 20 00:40:06 UTC 2024 x86_64 Ubuntu 24.04 LTS user-BOD-WXX9 /dev/tty

DISTRIB_ID=Ubuntu DISTRIB_RELEASE=24.04 DISTRIB_CODENAME=noble DISTRIB_DESCRIPTION="Ubuntu 24.04 LTS" Running under: Wayland Frozen: False Paths: kitty: /usr/bin/kitty base dir: /usr/lib/kitty extensions dir: /usr/lib/kitty/kitty system shell: /bin/bash Loaded config files: /home/user/.config/kitty/kitty.conf

Config options different from defaults: background_opacity 0.8 dynamic_background_opacity True font_family JetBrains Mono Light Nerd Font Complete Windows Compatible font_size 10.7 visual_bell_duration 0.05 Added shortcuts: ctrl+alt+enter → launch --cwd=current Colors: background #101000
foreground #fcfce5
visual_bell_color #777777

Important environment variables seen by the kitty process: PATH /home/user/.cargo/bin:/home/user/.nvm/versions/node/v20.12.2/bin:/home/user/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/snap/bin LANG ru_RU.UTF-8 SHELL /bin/bash DISPLAY :0 WAYLAND_DISPLAY wayland-0 USER USER_NAME XDG_RUNTIME_DIR /run/user/1000 XDG_DATA_DIRS /usr/share/ubuntu:/usr/share/gnome:/usr/local/share/:/usr/share/:/var/lib/snapd/desktop XDG_CONFIG_DIRS /etc/xdg/xdg-ubuntu:/etc/xdg XDG_CURRENT_DESKTOP ubuntu:GNOME XDG_MENU_PREFIX gnome- XDG_SESSION_CLASS user XDG_SESSION_DESKTOP ubuntu XDG_SESSION_TYPE wayland



**Additional context**
Try to reproduce the problem with `kitty --config NONE` if you cannot then post a minimal kitty.conf that reproduces the problem. If the problem involves interaction with some other terminal program post a minimal config for that program to reproduce the problem as well.
kovidgoyal commented 5 months ago

kitty has no control over what the OOM killer decides to do. Probably the OOM killer has some heuristics to avoid killing "known" terminal programs. You should report the discriminatory behavior to the kernel developers.

kovidgoyal commented 5 months ago

Actually, I am going to guess this is because VTE (the library gnome terminal uses) runs the shell in a new systemd scope by default. You can do the same thing in kitty by changing shell in kitty.conf to something like

shell systemd-run --user --scope --quiet kitten run-shell --shell=/bin/zsh

changing --shell to whatever you want.

leiserfg commented 5 months ago

Consider not using systemd-oomd in the desktop, use earlyoom instead, oomd likes to take down even the full desktop.