Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pidfd's are dup()ed twice #1675

Closed
arrowd opened this issue Mar 19, 2025 · 1 comment
Closed

pidfd's are dup()ed twice #1675

arrowd opened this issue Mar 19, 2025 · 1 comment
Labels

Comments

@arrowd
Copy link
Contributor

arrowd commented Mar 19, 2025

Operating System

Any

XDG Desktop Portal version

Git

Current Behavior

Not sure if this is a bug and hurts something, but I noticed that pidfd's obtained from the D-Bus GetConnectionCredentials API gets dup()ed twice:

  • First in xdp-app-info.c:xdp_connection_get_pidfd() before returning
  • Then in xdp-app-info.c:xdp_app_info_initialize() when constructing priv

It feels like the second dup() should be unnecessary?

@arrowd arrowd added the bug label Mar 19, 2025
@swick
Copy link
Collaborator

swick commented Mar 21, 2025

The fd we get in xdp_connection_get_pidfd we need to take from a GUnixFDList which doesn't allow us to steal a specific fd from that list, so we do have to dup it. It is closed by the autofd. Then in XdpAppInfo initialization we dup the fd again which is then owned by the object and is closed when it gets disposed. So it all works out, but we do not mark the fd's as FD_CLOEXEC and the last dup could be avoided. Created #1680 for that.

@swick swick closed this as completed Mar 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants