Repository: alacritty/alacritty (language: rust)

Issue:
Alacritty 0.13.2 (and 1cc08eb) leaks file descriptors
First of all, thank you for maintaining and developing Alacritty! I've encountered an issue where Alacritty leaks a number of file descriptors on my system (using `% alacritty`):
```
% ls -la /proc/self/fd
lrwx------ 64 user 16 Oct 21:43  0 -> /dev/pts/4
lrwx------ 64 user 16 Oct 21:43  1 -> /dev/pts/4
lrwx------ 64 user 16 Oct 21:43  2 -> /dev/pts/4
lr-x------ 64 user 16 Oct 21:43  15 -> pipe:[150277]
l-wx------ 64 user 16 Oct 21:43  16 -> pipe:[150277]
lr-x------ 64 user 16 Oct 21:43  19 -> pipe:[150280]
l-wx------ 64 user 16 Oct 21:43  20 -> pipe:[150280]
```

Every new alacritty subprocess inherits more file descriptors (using `% alacritty -e alacritty`):
```
% ls -la /proc/self/fd
lrwx------ 64 user 16 Oct 21:43  0 -> /dev/pts/5
lrwx------ 64 user 16 Oct 21:43  1 -> /dev/pts/5
lrwx------ 64 user 16 Oct 21:43  2 -> /dev/pts/5
lr-x------ 64 user 16 Oct 21:43  15 -> pipe:[152262]
l-wx------ 64 user 16 Oct 21:43  16 -> pipe:[152262]
lr-x------ 64 user 16 Oct 21:43  17 -> pipe:[167016]
l-wx------ 64 user 16 Oct 21:43  18 -> pipe:[167016]
lr-x------ 64 user 16 Oct 21:43  19 -> pipe:[152265]
l-wx------ 64 user 16 Oct 21:43  20 -> pipe:[152265]
lr-x------ 64 user 16 Oct 21:43  23 -> pipe:[167019]
l-wx------ 64 user 16 Oct 21:43  24 -> pipe:[167019]
```
This also applies to the `SpawnNewInstance` action.

The expected behavior is that subprocesses do not inherit any additional file descriptors (tested using a different terminal emulator `% st`):
```
% ls -la /proc/self/fd
lrwx------ 64 user 16 Oct 21:44  0 -> /dev/pts/4
lrwx------ 64 user 16 Oct 21:44  1 -> /dev/pts/4
lrwx------ 64 user 16 Oct 21:44  2 -> /dev/pts/4
```

I'm sure this is reproducible not just on my system, but I'd be happy to provide more information if needed.

### System

OS: Linux
Version: `alacritty 0.13.2` (also occurs with commit `1cc08eb`)
Linux/BSD: X11, picom and bspwm

### Logs

Crashes: N/A
Font/Terminal size:
```
[0.010115162s] [INFO ] [alacritty] Using GLX 1.4
[0.010219501s] [DEBUG] [alacritty] Picked GL Config:
                                     buffer_type: Some(Rgb { r_size: 8, g_size: 8, b_size: 8 })
                                     alpha_size: 8
                                     num_samples: 0
                                     hardware_accelerated: true
                                     supports_transparency: Some(true)
                                     config_api: Api(OPENGL | GLES1 | GLES2)
                                     srgb_capable: true
[0.010675829s] [INFO ] [alacritty] Window scale factor: 1
[0.016141222s] [DEBUG] [alacritty] Loading "ComicCode Nerd Font" font
[0.029547707s] [DEBUG] [crossfont] Loaded Face Face { ft_face: Font Face: Regular, load_flags: TARGET_LIGHT, render_mode: "Normal", lcd_filter: 1 }
[0.038463624s] [DEBUG] [crossfont] Loaded Face Face { ft_face: Font Face: Bold, load_flags: TARGET_LIGHT, render_mode: "Normal", lcd_filter: 1 }
[0.047688520s] [DEBUG] [crossfont] Loaded Face Face { ft_face: Font Face: Italic, load_flags: TARGET_LIGHT, render_mode: "Normal", lcd_filter: 1 }
[0.056412088s] [DEBUG] [crossfont] Loaded Face Face { ft_face: Font Face: Bold Italic, load_flags: TARGET_LIGHT, render_mode: "Normal", lcd_filter: 1 }
[0.122824677s] [INFO ] [alacritty] Running on NVIDIA GeForce GTX 1060 6GB/PCIe/SSE2
[0.122835576s] [INFO ] [alacritty] OpenGL version 3.3.0 NVIDIA 550.54.14, shader_version 3.30 NVIDIA via Cg compiler
[0.122842166s] [INFO ] [alacritty] Using OpenGL 3.3 renderer
[0.125721552s] [DEBUG] [alacritty] Enabled debug logging for OpenGL
[0.125730982s] [DEBUG] [alacritty] Filling glyph cache with common glyphs
[0.127609543s] [INFO ] [alacritty] Cell size: 7 x 15
[0.127616953s] [INFO ] [alacritty] Padding: 1 x 0
[0.127621533s] [INFO ] [alacritty] Width: 800, Height: 600
[0.132175231s] [INFO ] [alacritty] PTY dimensions: 40 x 114
[0.133500665s] [INFO ] [alacritty] Initialisation complete
[0.133786993s] [DEBUG] [alacritty] [gl_render] Buffer detailed info: Buffer object 2 (bound to GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB (0), GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB (1), GL_VERTEX_ATTRIB_ARRAY_BU
FFER_BINDING_ARB (2), GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB (3), GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB (4), and GL_ARRAY_BUFFER_ARB, usage hint is GL_STREAM_DRAW) will use VIDEO memory as the source for buf
fer object operations.
[0.141322377s] [DEBUG] [alacritty_terminal] New num_cols is 122 and num_lines is 94
[0.147082919s] [INFO ] [alacritty] Padding: 0 x 1
[0.147093859s] [INFO ] [alacritty] Width: 855, Height: 1412
[0.162072057s] [DEBUG] [alacritty] [gl_render] Buffer detailed info: Buffer object 3 (bound to GL_VERTEX_A
TTRIB_ARRAY_BUFFER_BINDING_ARB (0), GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB (1), and GL_ARRAY_BUFFER_ARB
, usage hint is GL_STATIC_DRAW) will use VIDEO memory as the source for buffer object operations.
[20.047925532s] [DEBUG] [alacritty_terminal] New num_cols is 122 and num_lines is 46
[20.050221571s] [INFO ] [alacritty] Padding: 0 x 7
[20.050232651s] [INFO ] [alacritty] Width: 855, Height: 704
[27.295697514s] [DEBUG] [alacritty_terminal] New num_cols is 122 and num_lines is 94
[27.298038453s] [INFO ] [alacritty] Padding: 0 x 1
[27.298053603s] [INFO ] [alacritty] Width: 855, Height: 1412
[28.009577023s] [INFO ] [alacritty] Goodbye
```
Keyboard and bindings: N/A



Discussion / hints:
>  Version: alacritty 0.13.2 (also occurs with commit 1cc08eb)

Have you tested previous versions?

I don't see how this would ever create issues, considering these file descriptors aren't leaked based on your observation (they just aren't cleared from child processes). But if it's something easy to fix it's probably not a bad idea to clean up.
Aren't those from mesa?
Not sure how it'll help, but on my system all of them got fixed with https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/31700

Though, I'm on Wayland and maybe something specific to x11 is getting leaked on your setup.
Ah, you have X11 specific stuff and maybe your mesa doesn't have 300 fds leaked yet.


That's your issue, which should be simple to fix


https://github.com/quininer/x11-clipboard/commit/a716f799e324a7a00b01d22e8da1acffbd468654

Fix patch:
diff --git a/Cargo.lock b/Cargo.lock
index cb1a64f2e72..55a50f33b31 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -2626,9 +2626,9 @@ dependencies = [
 
 [[package]]
 name = "x11-clipboard"
-version = "0.9.2"
+version = "0.9.3"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b98785a09322d7446e28a13203d2cae1059a0dd3dfb32cb06d0a225f023d8286"
+checksum = "662d74b3d77e396b8e5beb00b9cad6a9eccf40b2ef68cc858784b14c41d535a3"
 dependencies = [
  "libc",
  "x11rb",


Test patch: