* Make dup2 work
* Use `CloseCloExec` for closing O_CLOEXEC files
This commit is contained in:
Generated
+4
-4
@@ -461,12 +461,12 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "redox_event"
|
||||
version = "0.4.6"
|
||||
source = "git+https://gitlab.redox-os.org/EuclidDivisionLemma/event?branch=spawn#17c4e4c5f0aaf83a2a8057b78ad75364e1f2242a"
|
||||
version = "0.4.7"
|
||||
source = "git+https://gitlab.redox-os.org/EuclidDivisionLemma/event?branch=spawn#48847ea51f9d06c8e2fc7ba3441343d12944e482"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"libredox",
|
||||
"redox_syscall 0.8.0",
|
||||
"redox_syscall 0.9.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -481,7 +481,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "redox_syscall"
|
||||
version = "0.9.0"
|
||||
source = "git+https://gitlab.redox-os.org/EuclidDivisionLemma/syscall/?branch=spawn#4a768587a071f8c87e915c6b0836d272bed1d56c"
|
||||
source = "git+https://gitlab.redox-os.org/EuclidDivisionLemma/syscall/?branch=spawn#d28cf36f5a6684fcbf8be449af55e12d0024d503"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
]
|
||||
|
||||
@@ -464,7 +464,7 @@ pub fn fexec_impl(
|
||||
));
|
||||
|
||||
// Close all O_CLOEXEC file descriptors. TODO: close_range?
|
||||
{
|
||||
if extrainfo.same_process {
|
||||
// NOTE: This approach of implementing O_CLOEXEC will not work in multithreaded
|
||||
// scenarios. While execve() is undefined according to POSIX if there exist sibling
|
||||
// threads, it could still be allowed by keeping certain file descriptors and instead
|
||||
|
||||
@@ -1282,6 +1282,7 @@ impl Pal for Sys {
|
||||
0,
|
||||
u64::try_from(fd).map_err(|_| Errno(EBADFD))?,
|
||||
)?;
|
||||
Sys::close(src_fd as i32)?;
|
||||
}
|
||||
crate::header::spawn::Operation::Close(fd) => {
|
||||
new_file_table.call_wo(
|
||||
@@ -1293,18 +1294,24 @@ impl Pal for Sys {
|
||||
crate::header::spawn::Operation::Chdir(_) => todo!(),
|
||||
crate::header::spawn::Operation::FChdir(_) => todo!(),
|
||||
crate::header::spawn::Operation::Dup2(old, new) => {
|
||||
// new_file_table.call_wo(
|
||||
// [(old as usize).to_ne_bytes(), (new as usize).to_ne_bytes()]
|
||||
// .into_iter()
|
||||
// .flatten()
|
||||
// .collect::<Vec<u8>>()
|
||||
// .as_slice(),
|
||||
// syscall::CallFlags::empty(),
|
||||
// &[syscall::flag::FileTableVerb::Dup2 as u64],
|
||||
// )?;
|
||||
new_file_table.call_wo(
|
||||
[(old as usize).to_ne_bytes(), (new as usize).to_ne_bytes()]
|
||||
.into_iter()
|
||||
.flatten()
|
||||
.collect::<Vec<u8>>()
|
||||
.as_slice(),
|
||||
syscall::CallFlags::empty(),
|
||||
&[syscall::flag::FileTableVerb::Dup2 as u64],
|
||||
)?;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
new_file_table.call_wo(
|
||||
&[],
|
||||
syscall::CallFlags::empty(),
|
||||
&[syscall::flag::FileTableVerb::CloseCloExec as u64],
|
||||
)?;
|
||||
}
|
||||
|
||||
if let Some(attr) = fat {
|
||||
|
||||
Reference in New Issue
Block a user