mirror of
https://github.com/xen-project/xen.git
synced 2026-10-28 02:01:24 +01:00
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@citrix.com> Acked-by: Andrii Sultanov <andriy.sultanov@vates.tech>
This commit is contained in:
1 parent
46678752be
commit
7f18907452
1 file changed
+2
-4
@@ -155,9 +155,8 @@ exception Failed_to_connect
|
|||||||
let daemon_open () =
|
let daemon_open () =
|
||||||
try
|
try
|
||||||
let sockaddr = Unix.ADDR_UNIX(daemon_socket) in
|
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.connect sock sockaddr;
|
||||||
Unix.set_close_on_exec sock;
|
|
||||||
make sock
|
make sock
|
||||||
with _ -> raise Failed_to_connect
|
with _ -> raise Failed_to_connect
|
||||||
|
|
||||||
@@ -169,8 +168,7 @@ let domain_open () =
|
|||||||
with Unix.Unix_error(_, _, _) ->
|
with Unix.Unix_error(_, _, _) ->
|
||||||
"/proc/xen/xenbus" in
|
"/proc/xen/xenbus" in
|
||||||
|
|
||||||
let fd = Unix.openfile path [ Unix.O_RDWR ] 0o550 in
|
let fd = Unix.openfile path [ Unix.O_RDWR; Unix.O_CLOEXEC ] 0o550 in
|
||||||
Unix.set_close_on_exec fd;
|
|
||||||
make fd
|
make fd
|
||||||
|
|
||||||
let close xsh = Xsraw.close xsh.con
|
let close xsh = Xsraw.close xsh.con
|
||||||