swaywm / sway

i3-compatible Wayland compositor
https://swaywm.org
MIT License
14.49k stars 1.11k forks source link

ensure to CLOEXEC all FDs #4286

Closed ghost closed 2 years ago

ghost commented 5 years ago

It seems that sway leaks some file descriptors. For example /etc/sway/config but maybe also swaysock

btmcg commented 2 years ago

Could you tell me the steps you used to determine that sway is leaking fds?

Xyene commented 2 years ago

ls -al /proc/$(pidof sway)/fd is a quick way to see what Sway has open at any given time.

sammko commented 2 years ago

On my system I get the following descriptors in children of sway:

lrwx------ 1 sammko sammko 64 mar 13 00:59 0 -> /dev/tty1
l-wx------ 1 sammko sammko 64 mar 13 00:59 1 -> /dev/null
lrwx------ 1 sammko sammko 64 mar 13 00:59 19 -> /dev/dri/card0
l-wx------ 1 sammko sammko 64 mar 13 00:59 2 -> /dev/null
lrwx------ 1 sammko sammko 64 mar 13 00:59 5 -> anon_inode:[eventpoll]
lrwx------ 1 sammko sammko 64 mar 13 00:59 6 -> anon_inode:[eventpoll]

5, 6 and 19 seem to be leaked by sway. Missing CLOEXEC somewhere perhaps?

EDIT: 5 and 6 are not sway, it's coming from somewhere higher up on my system. 19 is wlroots. https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/3487

EDIT: 5 and 6 come from greetd, that's been already fixed in https://github.com/tokio-rs/mio/commit/c52635c76a59be28d0bf287a0bad6d6871a2e36c though.

bl4ckb0ne commented 2 years ago

Im closing the issue as I believe this is fixed. Open a new issue if you spot a new FD leaking.