As reported in the PR, both C_Accept and C_Socket call Disable_SIGPIPE
unconditionally, in other words even though the descriptor is invalid.
Tested on x86-64/Linux, applied on the mainline and 16 branch.
2026-10-07 Hodong Kim <[email protected]>
PR ada/127759
* libgnat/g-socthi.adb (C_Accept): Do not call Disable_SIGPIPE
on failure.
(C_Socket): Likewise.
--
Eric Botcazoudiff --git a/gcc/ada/libgnat/g-socthi.adb b/gcc/ada/libgnat/g-socthi.adb
index f7fa4007dd1..a369c98a9e2 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;