File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -53,6 +53,31 @@ impl<T: AsFd> io::Write for RawWriter<T> {
5353 }
5454}
5555
56+ // write_all retries with EINTR which is sometimes not compatible with GNU
57+ #[ cfg( any( unix, target_os = "wasi" ) ) ]
58+ pub trait AsFdExt {
59+ fn write_all_no_retry ( & self , buf : & [ u8 ] ) -> io:: Result < ( ) > ;
60+ }
61+ #[ cfg( any( unix, target_os = "wasi" ) ) ]
62+ impl < T : AsFd > AsFdExt for T {
63+ fn write_all_no_retry ( & self , mut buf : & [ u8 ] ) -> io:: Result < ( ) > {
64+ let fd = self . as_fd ( ) ;
65+ while !buf. is_empty ( ) {
66+ match rustix:: io:: write ( fd, buf) {
67+ Ok ( 0 ) => {
68+ return Err ( io:: Error :: new (
69+ io:: ErrorKind :: WriteZero ,
70+ "failed to write whole buffer" ,
71+ ) ) ;
72+ }
73+ Ok ( n) => buf = & buf[ n..] ,
74+ Err ( e) => return Err ( e. into ( ) ) ,
75+ }
76+ }
77+ Ok ( ( ) )
78+ }
79+ }
80+
5681/// abstraction wrapper for native file handle / file descriptor
5782// todo: remove clone introducing additional syscall dependency
5883pub struct OwnedFileDescriptorOrHandle {
You can’t perform that action at this time.
0 commit comments