-
- if cmd == this.eval_libc_i32("F_SETFD")? {
- // This does not affect the file itself. Certain flags might require changing the file
- // or the way it is accessed somehow.
- let flag = this.read_scalar(arg_op.unwrap())?.to_i32()?;
- // The only usage of this in stdlib at the moment is to enable the `FD_CLOEXEC` flag.
- let fd_cloexec = this.eval_libc_i32("FD_CLOEXEC")?;
- if let Some(FileHandle { flag: old_flag, .. }) =
- this.machine.file_handler.handles.get_mut(&fd)
- {
- // Check that the only difference between the old flag and the current flag is
- // exactly the `FD_CLOEXEC` value.
- if flag ^ *old_flag == fd_cloexec {
- *old_flag = flag;
- } else {
- throw_unsup_format!("Unsupported arg {:#x} for `F_SETFD`", flag);
- }
- }
- Ok(0)
- } else if cmd == this.eval_libc_i32("F_GETFD")? {