@@ -23,13 +23,16 @@ pub struct FileHandler {
23
23
handles : BTreeMap < i32 , FileHandle > ,
24
24
}
25
25
26
+ // fd numbers 0, 1, and 2 are reserved for stdin, stdout, and stderr
27
+ const MIN_NORMAL_FILE_FD : i32 = 3 ;
28
+
26
29
impl FileHandler {
27
30
fn insert_fd ( & mut self , file_handle : FileHandle ) -> i32 {
28
- self . insert_fd_with_min_fd ( file_handle, 3 )
31
+ self . insert_fd_with_min_fd ( file_handle, 0 )
29
32
}
30
33
31
34
fn insert_fd_with_min_fd ( & mut self , file_handle : FileHandle , min_fd : i32 ) -> i32 {
32
- let min_fd = std:: cmp:: max ( min_fd, 3 ) ;
35
+ let min_fd = std:: cmp:: max ( min_fd, MIN_NORMAL_FILE_FD ) ;
33
36
34
37
// Find the lowest unused FD, starting from min_fd. If the first such unused FD is in
35
38
// between used FDs, the find_map combinator will return it. If the first such unused FD
@@ -171,7 +174,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
171
174
// because exec() isn't supported. The F_DUPFD and F_DUPFD_CLOEXEC commands only
172
175
// differ in whether the FD_CLOEXEC flag is pre-set on the new file descriptor,
173
176
// thus they can share the same implementation here.
174
- if fd <= 2 {
177
+ if fd < MIN_NORMAL_FILE_FD {
175
178
throw_unsup_format ! ( "Duplicating file descriptors for stdin, stdout, or stderr is not supported" )
176
179
}
177
180
let start_op = start_op. ok_or_else ( || {
0 commit comments