mirror of
https://github.com/asterinas/asterinas.git
synced 2025-06-23 17:33:23 +00:00
Support the close-on-exec file descriptor flag
This commit is contained in:
committed by
Tate, Hongliang Tian
parent
a6bb7c7bf5
commit
3de5c42afd
@ -2,7 +2,7 @@
|
||||
|
||||
use super::{SyscallReturn, SYS_SOCKETPAIR};
|
||||
use crate::{
|
||||
fs::file_table::FileDescripter,
|
||||
fs::file_table::{FdFlags, FileDescripter},
|
||||
log_syscall_entry,
|
||||
net::socket::unix::UnixStreamSocket,
|
||||
prelude::*,
|
||||
@ -37,9 +37,14 @@ pub fn sys_socketpair(domain: i32, type_: i32, protocol: i32, sv: Vaddr) -> Resu
|
||||
|
||||
let socket_fds = {
|
||||
let current = current!();
|
||||
let mut filetable = current.file_table().lock();
|
||||
let fd_a = filetable.insert(socket_a);
|
||||
let fd_b = filetable.insert(socket_b);
|
||||
let mut file_table = current.file_table().lock();
|
||||
let fd_flags = if sock_flags.contains(SockFlags::SOCK_CLOEXEC) {
|
||||
FdFlags::CLOEXEC
|
||||
} else {
|
||||
FdFlags::empty()
|
||||
};
|
||||
let fd_a = file_table.insert(socket_a, fd_flags);
|
||||
let fd_b = file_table.insert(socket_b, fd_flags);
|
||||
SocketFds(fd_a, fd_b)
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user