Skip to content

Avoid closing fds 0/1/2, reduce duplication handling fd arguments - #6598

Merged
smcv merged 2 commits into
flatpak:mainfrom
smcv:fd-arguments-again
Apr 10, 2026
Merged

smcv merged 2 commits into
flatpak:mainfrom
smcv:fd-arguments-again

Conversation

@smcv

@smcv smcv commented Apr 10, 2026 •

Copy link
Copy Markdown
Collaborator

Follow-up after fixing #6582.

  • app, context: Never close fds 0, 1 or 2

    These fds are stdin, stdout and stderr respectively, and are expected
    to remain open at all times (if they are not needed then they can point
    to /dev/null, but they should always be open). If the user gives us
    --env-fd=2 or similar, we don't want to close fd 2 before exiting
    unsuccessfully: that would give us nowhere to display the error message.

  • app, context: Factor out flatpak_accept_fd_argument()

smcv added 2 commits April 10, 2026 15:11
These fds are stdin, stdout and stderr respectively, and are expected
to remain open at all times (if they are not needed then they can point
to /dev/null, but they should always be open). If the user gives us
`--env-fd=2` or similar, we don't want to close fd 2 before exiting
unsuccessfully: that would give us nowhere to display the error message.

Signed-off-by: Simon McVittie <[email protected]>
@smcv smcv changed the title Fd arguments again Avoid closing fds 0/1/2, reduce duplication handling fd arguments Apr 10, 2026
@smcv
smcv requested a review from swick April 10, 2026 14:15
@smcv

smcv commented Apr 10, 2026

Copy link
Copy Markdown
Collaborator Author

I'm not sure whether we want both of these in 1.16, or only the first.

@swick

swick commented Apr 10, 2026

Copy link
Copy Markdown
Collaborator

With the amount of code we pushed into 1.16 I don't think it matters to add one more commit, and at least then we have the same code in main as well.

@smcv

smcv commented Apr 10, 2026

Copy link
Copy Markdown
Collaborator Author

With the amount of code we pushed into 1.16 I don't think it matters to add one more commit, and at least then we have the same code in main as well.

Yeah, fair enough.

@smcv
smcv added this pull request to the merge queue Apr 10, 2026
Merged via the queue into flatpak:main with commit d42037c Apr 10, 2026
11 checks passed
@smcv
smcv deleted the fd-arguments-again branch April 10, 2026 16:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants