Repository: kovidgoyal/kitty

Issue:
Can not launch a program with the --type=background option
**Describe the bug**
The `--type=background` option of the `launch` command appears to be broken.

**To Reproduce**
Steps to reproduce the behavior:
1. Install gVim (or VS Code, or gedit, which is part of GNOME).
2. Add the following to `kitty.conf`:
    ```
    map f12 launch --stdin-source=@screen_scrollback --type=background gvim -
    ```
3. Launch kitty.
4. F12

**Expected behavior**
1. The scrollback shall open in a new gVim window.
2. The originating shell window shall be available for me to type more commands.

**Observed behavior**
Nothing happens.  Silent.

**Environment details**
Ubuntu 20.04 LTS

```
$ kitty --debug-config
kitty 0.20.3 (6c0730fef4) created by Kovid Goyal
Linux byteevo-scm 5.8.0-50-generic #56~20.04.1-Ubuntu SMP Mon Apr 12 21:46:35 UTC 2021 x86_64
Ubuntu 20.04.2 LTS \n \l
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=20.04
DISTRIB_CODENAME=focal
DISTRIB_DESCRIPTION="Ubuntu 20.04.2 LTS"
Loaded config files: /home/precor/.config/kitty/kitty.conf
Running under: X11

Config options different from defaults:
active_tab_font_style         (True, False)
adjust_line_height            1
enabled_layouts               ['splits', 'fat', 'grid', 'horizontal', 'stack', 'tall', 'vertical']
font_family                   Hack
initial_window_height         (32, 'cells')
initial_window_width          (128, 'cells')
placement_strategy            top-left
remember_window_size          False
scrollback_pager_history_size 33554432
tab_bar_edge                  1
tab_bar_style                 powerline
window_padding_width          FloatEdges(left=1.0, top=10.0, right=1.0, bottom=0)
Added shortcuts:
	f1 KeyAction(func='toggle_marker', args=['regex', ((1, '\\bERROR:?'), (2, '\\bWARNING:?'), (3, '^FAILED')), re.IGNORECASE|re.UNICODE])
	f12 KeyAction(func='launch', args=['--stdin-source=@screen_scrollback', '--type=background', 'gvim', '-'])
	ctrl+l KeyAction(func='combine', args=(KeyAction(func='clear_terminal', args=['scrollback', True]), KeyAction(func='send_text', args=['normal,application', b'\x0c'])))
	ctrl+tab KeyAction(func='next_window', args=())
	ctrl+page_up KeyAction(func='previous_tab', args=())
	ctrl+page_down KeyAction(func='next_tab', args=())
	shift+ctrl+\ KeyAction(func='combine', args=(KeyAction(func='new_window', args=()), KeyAction(func='new_window', args=()), KeyAction(func='goto_layout', args=['tall']), KeyAction(func='resize_window', args=['shorter', 12])))
	shift+ctrl+tab KeyAction(func='previous_window', args=())
	alt+ctrl+d KeyAction(func='launch', args=['--location=hsplit', '--cwd=current'])
	alt+ctrl+r KeyAction(func='launch', args=['--location=vsplit', '--cwd=current'])
Changed shortcuts:
	shift+ctrl+h KeyAction(func='launch', args=['--stdin-source=@screen_scrollback', '--stdin-add-formatting', '--type=overlay', '/home/precor/.local/share/precor/kitty-scrollback-helper.sh', '@input-line-number', '-R'])
	shift+ctrl+t KeyAction(func='launch', args=['--type=tab', '--cwd=current'])
	shift+ctrl+enter KeyAction(func='new_window_with_cwd', args=())
```

**Additional context**
1. kitty is compiled from source.  `master` branch @ `6c0730fe`.
2. Changing the `background` to `overlay` fixes the issue.
3. I have tried this with gedit, VS Code, and gVim with the same result in all 3 cases.


Discussion:

Resolving patch:
diff --git a/kitty/boss.py b/kitty/boss.py
--- a/kitty/boss.py
+++ b/kitty/boss.py
@@ -1221,6 +1221,8 @@ def run_background_process(
         cwd_from: Optional[int] = None
     ) -> None:
         import subprocess
+        if env:
+            env = {**os.environ, **env}
         if cwd_from:
             with suppress(Exception):
                 cwd = cwd_of_process(cwd_from)


Test patch: