@@ -130,7 +130,7 @@ let test_read_exact () =
130130 let ( / ) = Eio.Path. ( / ) in
131131 let path = env#cwd / " test.data" in
132132 let msg = " hello" in
133- Eio.Path. save path (" !" ^ msg) ~create: (`Exclusive 0o600 );
133+ Eio.Path. save path (" !" ^ msg) ~create: (`Or_truncate 0o600 );
134134 Switch. run @@ fun sw ->
135135 let fd = Eio_linux.Low_level. openat2 ~sw
136136 ~access: `R
@@ -162,7 +162,7 @@ let test_statx () =
162162 Eio_linux. run ~queue_depth: 4 @@ fun env ->
163163 let ( / ) = Eio.Path. ( / ) in
164164 let path = env#cwd / " test2.data" in
165- Eio.Path. with_open_out path ~create: (`Exclusive 0o600 ) @@ fun file ->
165+ Eio.Path. with_open_out path ~create: (`Or_truncate 0o600 ) @@ fun file ->
166166 Eio.Flow. copy_string " hello" file;
167167 let buf = Uring.Statx. create () in
168168 let test expected_len ~follow dir path =
@@ -198,6 +198,19 @@ let test_statx () =
198198 );
199199 ()
200200
201+ (* Ensure that an OCaml signal handler will run, even if we're sleeping in liburing at the time.
202+ The problem here is that [__sys_io_uring_enter2] doesn't return EINTR, because it did successfully
203+ submit an item. This causes liburing to retry without giving our OCaml signal handler a chance to run.
204+ Note: we can't run this test with a timeout because liburing does return in that case! *)
205+ let test_signal_race () =
206+ Eio_linux. run @@ fun _env ->
207+ let cond = Eio.Condition. create () in
208+ let handle _ = Eio.Condition. broadcast cond in
209+ Sys. (set_signal sigalrm) (Signal_handle handle);
210+ Fiber. both
211+ (fun () -> Eio.Condition. await_no_mutex cond)
212+ (fun () -> ignore (Unix. setitimer ITIMER_REAL { it_interval = 0. ; it_value = 0.001 } : Unix.interval_timer_status ))
213+
201214let () =
202215 let open Alcotest in
203216 run " eio_linux" [
@@ -211,5 +224,6 @@ let () =
211224 test_case " read_exact" `Quick test_read_exact;
212225 test_case " expose_backend" `Quick test_expose_backend;
213226 test_case " statx" `Quick test_statx;
227+ test_case " signal_race" `Quick test_signal_race;
214228 ];
215229 ]
0 commit comments