Skip to content

Commit 4249499

Browse files
libvncserver: don't exit listener thread on EINTR from select()
listenerRun() exited on any select() failure, including EINTR, which is never restarted by SA_RESTART (see signal(7)). A single stray signal delivered to the listener thread thus permanently killed the accept loop while the listening sockets stayed open: clients still completed the TCP handshake but hung forever waiting for the RFB protocol version greeting, because nothing called accept() anymore. Observed in the field on Android, where the platform's debugging and profiling infrastructure routinely delivers signals to app threads. Treat EINTR/EAGAIN as benign and retry. Closes #732 Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
1 parent 6389c1c commit 4249499

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

src/libvncserver/main.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -651,6 +651,8 @@ listenerRun(void *data)
651651
tv.tv_sec = 0;
652652
tv.tv_usec = screen->select_timeout_usec;
653653
if (select(screen->maxFd+1, &listen_fds, NULL, NULL, &tv) == -1) {
654+
if (errno == EINTR || errno == EAGAIN)
655+
continue; /* interrupted by a signal: benign, retry */
654656
rfbLogPerror("listenerRun: error in select");
655657
return THREAD_ROUTINE_RETURN_VALUE;
656658
}

0 commit comments

Comments
 (0)