Skip to content

GUACAMOLE-2239: guac_wait_for_fd() does not correctly retry on EINTR.#644

Closed
bbennett-ks wants to merge 1 commit intoapache:staging/1.6.1from
bbennett-ks:GUACAMOLE-2239-retry-on-eintr-wait-fd
Closed

GUACAMOLE-2239: guac_wait_for_fd() does not correctly retry on EINTR.#644
bbennett-ks wants to merge 1 commit intoapache:staging/1.6.1from
bbennett-ks:GUACAMOLE-2239-retry-on-eintr-wait-fd

Conversation

@bbennett-ks
Copy link
Contributor

Summary

This PR hardens guac_wait_for_fd() against signal interruption (EINTR). This is a subset of GUACAMOLE-2238.

When a signal is delivered (e.g. when a child process exits), some blocking syscalls can return early with -1 with errno = EINTR . This is not a hard failure: the syscall should be retried.

This PR adds EINTR retry loops around blocking calls in various guacamole-server. Equivalent handling for the Windows equivalent was also added.

Without retry, signal (async) delivery can cause guac_wait_for_fd() to intermittently fail.

select Handling

int select(int nfds, fd_set *_Nullable restrict readfds, fd_set *_Nullable restrict writefds, fd_set *_Nullable restrict exceptfds, struct timeval *_Nullable restrict timeout);

Special care has been taken with the select system call, as it has parameters which are modified by the system: how these parameters are handled on retry must be considered. Based on the Linux man page:

On error, -1 is returned, and is set to indicate the error; the file descriptor sets are unmodified, and timeout becomes undefined.

select retry is based on this.

Copy link
Contributor

@necouchman necouchman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also good with this one, but will wait for @mike-jumper comments, as well.

@necouchman necouchman requested a review from mike-jumper March 6, 2026 23:35
@bbennett-ks bbennett-ks force-pushed the GUACAMOLE-2239-retry-on-eintr-wait-fd branch from 4eec449 to 68d070b Compare March 7, 2026 00:45
@bbennett-ks
Copy link
Contributor Author

Moving forward with GUACAMOLE-2238.

@bbennett-ks bbennett-ks closed this Mar 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants