[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[xen staging] tools/ocaml/libs/xs: Create FDs with the correct CLOEXEC status



commit 7f18907452ca85b7b36ce7d89c14f1108ff39331
Author:     Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
AuthorDate: Mon Oct 12 19:48:56 2026 +0100
Commit:     Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
CommitDate: Mon Oct 26 18:36:52 2026 +0000

    tools/ocaml/libs/xs: Create FDs with the correct CLOEXEC status
    
    ... rather than editing them after the fact.
    
    This capability exists from Ocaml 4.05 which is also our minimum supported
    version.
    
    Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
    Acked-by: Andrii Sultanov <andriy.sultanov@xxxxxxxxxx>
---
 tools/ocaml/libs/xs/xs.ml | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/tools/ocaml/libs/xs/xs.ml b/tools/ocaml/libs/xs/xs.ml
index addccc8009..a088d67a8c 100644
--- a/tools/ocaml/libs/xs/xs.ml
+++ b/tools/ocaml/libs/xs/xs.ml
@@ -155,9 +155,8 @@ exception Failed_to_connect
 let daemon_open () =
   try
     let sockaddr = Unix.ADDR_UNIX(daemon_socket) in
-    let sock = Unix.socket Unix.PF_UNIX Unix.SOCK_STREAM 0 in
+    let sock = Unix.socket ~cloexec:true Unix.PF_UNIX Unix.SOCK_STREAM 0 in
     Unix.connect sock sockaddr;
-    Unix.set_close_on_exec sock;
     make sock
   with _ -> raise Failed_to_connect
 
@@ -169,8 +168,7 @@ let domain_open () =
     with Unix.Unix_error(_, _, _) ->
       "/proc/xen/xenbus" in
 
-  let fd = Unix.openfile path [ Unix.O_RDWR ] 0o550 in
-  Unix.set_close_on_exec fd;
+  let fd = Unix.openfile path [ Unix.O_RDWR; Unix.O_CLOEXEC ] 0o550 in
   make fd
 
 let close xsh = Xsraw.close xsh.con
--
generated by git-patchbot for /home/xen/git/xen.git#staging



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.