]> xenbits.xensource.com Git - people/andrewcoop/xen.git/commit
tools/libxs: Fix CLOEXEC handling in get_dev()
authorAndrew Cooper <andrew.cooper3@citrix.com>
Fri, 28 Jun 2024 13:10:12 +0000 (14:10 +0100)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Tue, 2 Jul 2024 09:51:06 +0000 (10:51 +0100)
commitbf7c1464706adfa903f1e7d59383d042c3a88e39
tree23f3e1215020bba0a20df9aa2cab4405cd3bbcd5
parent4c3a618b0adaa0cd59e0fa0898bb60978b8b3a5f
tools/libxs: Fix CLOEXEC handling in get_dev()

Move the O_CLOEXEC compatibility outside of an #ifdef USE_PTHREAD block.

Introduce set_cloexec() to wrap fcntl() setting FD_CLOEXEC.  It will be reused
for other CLOEXEC fixes too.

Use set_cloexec() when O_CLOEXEC isn't available as a best-effort fallback.

Fixes: f4f2f3402b2f ("tools/libxs: Open /dev/xen/xenbus fds as O_CLOEXEC")
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Juergen Gross <jgross@suse.com>
Acked-by: Anthony PERARD <anthony.perard@vates.tech>
tools/libs/store/xs.c