Sockets are help open by child processes after exiting #14510

Closed
opened 2026-02-22 01:08:38 -05:00 by deekerman · 2 comments
Owner

Originally created by @szaszm on GitHub (Apr 11, 2023).

qBittorrent & operating system versions

qBittorrent: 4.5.2 x64
Operating system: Arch Linux
Qt: 5.15.8
libtorrent-rasterbar: 2.0.8

What is the problem?

Child processes inherit all open files, including sockets, and keep them open even after qBittorrent is closed. This causes failure to listen on the configured port when qBittorrent is restarted, but any of the previously spawned processes are still running. I've experienced this through starting a video in mpv from the Contents tab, or opening an image in gwenview, then trying to restart qBittorrent without closing all of these first.

qBittorrent should close all open file descriptors, except stdin, stdout and stderr, after fork and before exec, possibly by using the O_CLOEXEC/SOCK_CLOEXEC flag on open/socket.

Steps to reproduce

  1. Make sure to have a torrent with files that can be opened
  2. Open a file from the Contents tab of a torrent
  3. Restart qBittorrent while keeping the other file open
  4. qBittorrent will fail to listen for incoming connections, because the socket is still open. Checking the port via ss -tlnp will list the file viewer (e.g. mpv, gwenview) as the processes having the listening socket open on the configured port.

Additional context

image

Log(s) & preferences file(s)

No response

Originally created by @szaszm on GitHub (Apr 11, 2023). ### qBittorrent & operating system versions qBittorrent: 4.5.2 x64 Operating system: Arch Linux Qt: 5.15.8 libtorrent-rasterbar: 2.0.8 ### What is the problem? Child processes inherit all open files, including sockets, and keep them open even after qBittorrent is closed. This causes failure to listen on the configured port when qBittorrent is restarted, but any of the previously spawned processes are still running. I've experienced this through starting a video in mpv from the Contents tab, or opening an image in gwenview, then trying to restart qBittorrent without closing all of these first. qBittorrent should close all open file descriptors, except stdin, stdout and stderr, after `fork` and before `exec`, possibly by using the `O_CLOEXEC`/`SOCK_CLOEXEC` flag on `open`/`socket`. ### Steps to reproduce 1. Make sure to have a torrent with files that can be opened 2. Open a file from the Contents tab of a torrent 3. Restart qBittorrent while keeping the other file open 4. qBittorrent will fail to listen for incoming connections, because the socket is still open. Checking the port via `ss -tlnp` will list the file viewer (e.g. mpv, gwenview) as the processes having the listening socket open on the configured port. ### Additional context ![image](https://user-images.githubusercontent.com/1170582/231193123-39636908-4eeb-4a04-98eb-2546404b9a67.png) ### Log(s) & preferences file(s) _No response_
deekerman 2026-02-22 01:08:38 -05:00
  • closed this issue
  • added the
    Duplicate
    label
Author
Owner

@cteqpah commented on GitHub (Apr 27, 2023):

@szaszm It's a long standing bug. I hope it will be fixed soon because it can be really annoying when you forget about this and wonder why your instance can't connect. Check this comment.

@cteqpah commented on GitHub (Apr 27, 2023): @szaszm It's a long standing bug. I hope it will be fixed soon because it can be really annoying when you forget about this and wonder why your instance can't connect. Check [this comment](https://github.com/qbittorrent/qBittorrent/issues/10312#issuecomment-1494954451).
Author
Owner

@szaszm commented on GitHub (Apr 27, 2023):

Closing this issue as duplicate of #10312

@szaszm commented on GitHub (Apr 27, 2023): Closing this issue as duplicate of #10312
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/qBittorrent#14510
No description provided.