should only be called on empty fdmap
(&mut self)
| 41 | // #[external_method(into)] |
| 42 | #[requires (self.counter == 0)] //should only be called on empty fdmap |
| 43 | pub fn init_std_fds(&mut self) -> RuntimeResult<()> { |
| 44 | let stdin_fd = stdin().as_raw_fd(); |
| 45 | let stdout_fd = stdout().as_raw_fd(); |
| 46 | let stderr_fd = stderr().as_raw_fd(); |
| 47 | if (stdin_fd >= 0) && (stdout_fd >= 0) && (stderr_fd >= 0) { |
| 48 | // upcasting i32 => usize is safe since we checked that it is positive |
| 49 | // viper overflow checker would yell at us if this was not the case |
| 50 | self.create(HostFd::from_raw(stdin_fd as usize)); |
| 51 | self.create(HostFd::from_raw(stdout_fd as usize)); |
| 52 | self.create(HostFd::from_raw(stderr_fd as usize)); |
| 53 | return Ok(()); |
| 54 | } |
| 55 | Err(Emfile) // File descriptor failure |
| 56 | } |
| 57 | |
| 58 | #[pure] |
| 59 | #[requires (index < MAX_SBOX_FDS )] |
no test coverage detected