@@ -1176,27 +1176,38 @@ let raw_console_proxy sockaddr =
1176
1176
) else if ! final then
1177
1177
finished := true
1178
1178
else
1179
- let r, _, _ = Unix. select [Unix. stdin; fd] [] [] (- 1. ) in
1180
- if List. mem Unix. stdin r then (
1181
- let b =
1182
- Unix. read Unix. stdin buf_remote ! buf_remote_end
1183
- (block - ! buf_remote_end)
1184
- in
1185
- let i = ref ! buf_remote_end in
1186
- while
1187
- ! i < ! buf_remote_end + b
1188
- && Char. code (Bytes. get buf_remote ! i) <> 0x1d
1189
- do
1190
- incr i
1191
- done ;
1192
- if ! i < ! buf_remote_end + b then final := true ;
1193
- buf_remote_end := ! i
1194
- ) ;
1195
- if List. mem fd r then
1196
- let b =
1197
- Unix. read fd buf_local ! buf_local_end (block - ! buf_local_end)
1198
- in
1199
- buf_local_end := ! buf_local_end + b
1179
+ let epoll = Polly. create () in
1180
+ List. iter
1181
+ (fun fd -> Polly. add epoll fd Polly.Events. inp)
1182
+ [Unix. stdin; fd] ;
1183
+ Fun. protect
1184
+ ~finally: (fun () -> Polly. close epoll)
1185
+ (fun () ->
1186
+ ignore
1187
+ @@ Polly. wait epoll 2 (- 1 ) (fun _ file_desc _ ->
1188
+ if Unix. stdin = file_desc then (
1189
+ let b =
1190
+ Unix. read Unix. stdin buf_remote ! buf_remote_end
1191
+ (block - ! buf_remote_end)
1192
+ in
1193
+ let i = ref ! buf_remote_end in
1194
+ while
1195
+ ! i < ! buf_remote_end + b
1196
+ && Char. code (Bytes. get buf_remote ! i) <> 0x1d
1197
+ do
1198
+ incr i
1199
+ done ;
1200
+ if ! i < ! buf_remote_end + b then final := true ;
1201
+ buf_remote_end := ! i
1202
+ ) ;
1203
+ if fd = file_desc then
1204
+ let b =
1205
+ Unix. read fd buf_local ! buf_local_end
1206
+ (block - ! buf_local_end)
1207
+ in
1208
+ buf_local_end := ! buf_local_end + b
1209
+ )
1210
+ )
1200
1211
done
1201
1212
in
1202
1213
let delay = ref 0.1 in
0 commit comments