File tree Expand file tree Collapse file tree 2 files changed +12
-2
lines changed Expand file tree Collapse file tree 2 files changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -4827,6 +4827,7 @@ pub mod funcs {
4827
4827
mibp : * mut c_int ,
4828
4828
sizep : * mut size_t )
4829
4829
-> c_int ;
4830
+ pub fn getdtablesize ( ) -> c_int ;
4830
4831
pub fn madvise ( addr : * mut c_void , len : size_t , advice : c_int )
4831
4832
-> c_int ;
4832
4833
pub fn mincore ( addr : * mut c_void , len : size_t , vec : * mut c_uchar )
@@ -4841,6 +4842,8 @@ pub mod funcs {
4841
4842
use types:: os:: arch:: c95:: { c_uchar, c_int, size_t} ;
4842
4843
4843
4844
extern {
4845
+ #[ cfg( not( all( target_os = "android" , target_arch = "aarch64" ) ) ) ]
4846
+ pub fn getdtablesize ( ) -> c_int ;
4844
4847
pub fn ioctl ( d : c_int , request : c_int , ...) -> c_int ;
4845
4848
pub fn madvise ( addr : * mut c_void , len : size_t , advice : c_int )
4846
4849
-> c_int ;
Original file line number Diff line number Diff line change @@ -82,6 +82,14 @@ impl Process {
82
82
extern { static mut environ: * const c_void ; }
83
83
environ = envp;
84
84
}
85
+ #[ cfg( all( target_os = "android" , target_arch = "aarch64" ) ) ]
86
+ unsafe fn getdtablesize ( ) -> c_int {
87
+ libc:: sysconf ( libc:: consts:: os:: sysconf:: _SC_OPEN_MAX) as c_int
88
+ }
89
+ #[ cfg( not( all( target_os = "android" , target_arch = "aarch64" ) ) ) ]
90
+ unsafe fn getdtablesize ( ) -> c_int {
91
+ libc:: funcs:: bsd44:: getdtablesize ( )
92
+ }
85
93
86
94
unsafe fn set_cloexec ( fd : c_int ) {
87
95
let ret = c:: ioctl ( fd, c:: FIOCLEX ) ;
@@ -223,8 +231,7 @@ impl Process {
223
231
if !setup ( err_fd, libc:: STDERR_FILENO ) { fail ( & mut output) }
224
232
225
233
// close all other fds
226
- let open_max = libc:: sysconf ( libc:: consts:: os:: sysconf:: _SC_OPEN_MAX) ;
227
- for fd in ( 3 ..open_max) . rev ( ) {
234
+ for fd in ( 3 ..getdtablesize ( ) ) . rev ( ) {
228
235
if fd != output. fd ( ) {
229
236
let _ = close ( fd as c_int ) ;
230
237
}
You can’t perform that action at this time.
0 commit comments