===================================================================
@@ -2211,6 +2211,24 @@
Insert_Socket_In_Set (Item.Set'Access, C.int (Socket));
end Set;
+ -----------------------
+ -- Set_Close_On_Exec --
+ -----------------------
+
+ procedure Set_Close_On_Exec
+ (Socket : Socket_Type;
+ Close_On_Exec : Boolean;
+ Status : out Boolean)
+ is
+ function C_Set_Close_On_Exec
+ (Socket : Socket_Type; Close_On_Exec : C.int)
+ return C.int;
+ pragma Import (C, C_Set_Close_On_Exec, "__gnat_set_close_on_exec");
+
+ begin
+ Status := C_Set_Close_On_Exec (Socket, Boolean'Pos (Close_On_Exec)) = 0;
+ end Set_Close_On_Exec;
+
----------------------
-- Set_Forced_Flags --
----------------------
===================================================================
@@ -979,6 +979,17 @@
-- socket. Count is set to the count of transmitted stream elements. Flags
-- allow control over transmission.
+ procedure Set_Close_On_Exec
+ (Socket : Socket_Type;
+ Close_On_Exec : Boolean;
+ Status : out Boolean);
+ -- When Close_On_Exec is True, mark Socket to be closed automatically when
+ -- a new program is executed by the calling process (i.e. prevent Socket
+ -- from being inherited by child processes). When Close_On_Exec is False,
+ -- mark Socket to not be closed on exec (i.e. allow it to be inherited).
+ -- Status is False if the operation could not be performed, or is not
+ -- supported on the target platform.
+
procedure Set_Socket_Option
(Socket : Socket_Type;
Level : Level_Type := Socket_Level;