WEDNESDAY, OCTOBER 7, 2026
ada
Ada: Fix oversight in GNAT.Sockets.Thin
Corrects unconditional `Disable_SIGPIPE` calls in Ada's GNAT.Sockets.Thin.
An oversight in the Ada GNAT.Sockets.Thin module caused Disable_SIGPIPE to be called even with invalid socket descriptors. This commit modifies C_Accept and C_Socket to only call Disable_SIGPIPE when the descriptor is valid, preventing potential issues and adhering to correct error handling.
In Details
The GNAT.Sockets.Thin module in GCC's Ada front-end contains C bindings for socket operations. This change corrects C_Accept and C_Socket by adding checks to ensure Disable_SIGPIPE is only invoked when the socket descriptor is valid. Previously, it was called unconditionally, leading to incorrect behavior when socket creation or acceptance failed.
For Context
- SIGPIPE
- A signal sent to a process when it attempts to write to a pipe or socket whose reading end has been closed. Disabling this signal can prevent programs from crashing in certain network scenarios.
- GNAT.Sockets.Thin
- A module within GCC's Ada library providing a thin wrapper around POSIX socket functions, likely for performance or simplicity.
- socket descriptor
- An integer handle or identifier that the operating system uses to refer to an open network socket. It's used in system calls to perform operations on the socket.