daemon: Use O_CLOEXEC instead of Unix.set_close_on_exec.

In fact we already used O_CLOEXEC in daemon/inspect_fs_windows.c,
meaning that the code wouldn't have compiled on OCaml 3.11.

Thanks: Pino Toscano
This commit is contained in:
Richard W.M. Jones
2017-10-05 10:29:32 +01:00
parent 457bdb4e2f
commit 45d6f8bef9

View File

@@ -49,8 +49,7 @@ let map_block_devices ~return_md f =
List.filter (
fun dev ->
try
let fd = openfile ("/dev/" ^ dev) [O_RDONLY] 0 in
Unix.set_close_on_exec fd; (* XXX *)
let fd = openfile ("/dev/" ^ dev) [O_RDONLY; O_CLOEXEC] 0 in
close fd;
true
with _ -> false