https://gcc.gnu.org/g:b4ec88ebf3e3f495736deb25849990034d04195e
commit r17-4970-gb4ec88ebf3e3f495736deb25849990034d04195e Author: Hodong Kim <[email protected]> Date: Wed Oct 7 23:41:24 2026 +0200 Ada: Fix oversight in GNAT.Sockets.Thin As reported in the PR, both C_Accept and C_Socket call Disable_SIGPIPE unconditionally, in other words even though the descriptor is invalid. gcc/ada/ PR ada/127759 * libgnat/g-socthi.adb (C_Accept): Do not call Disable_SIGPIPE on failure. (C_Socket): Likewise. Diff: --- gcc/ada/libgnat/g-socthi.adb | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/gcc/ada/libgnat/g-socthi.adb b/gcc/ada/libgnat/g-socthi.adb index f7fa4007dd1b..a369c98a9e22 100644 --- a/gcc/ada/libgnat/g-socthi.adb +++ b/gcc/ada/libgnat/g-socthi.adb @@ -187,7 +187,10 @@ package body GNAT.Sockets.Thin is Discard := C_Ioctl (R, SOSC.FIONBIO, Val'Access); end if; - Disable_SIGPIPE (R); + if R /= Failure then + Disable_SIGPIPE (R); + end if; + return R; end C_Accept; @@ -533,7 +536,11 @@ package body GNAT.Sockets.Thin is Discard := C_Ioctl (R, SOSC.FIONBIO, Val'Access); Set_Non_Blocking_Socket (R, False); end if; - Disable_SIGPIPE (R); + + if R /= Failure then + Disable_SIGPIPE (R); + end if; + return R; end C_Socket;
