Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
MeiK2333 committed Apr 11, 2024
1 parent 0e1bb49 commit 05381f2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/sys/linux/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ fn runit_child(sandbox: &Sandbox, runit_exists: bool) -> i32 {
}
// 重定向输入输出流
if let Some(file) = &sandbox.input {
let f = CString::new(file).unwrap();
let f = CString::new(file.clone()).unwrap();
let fd = unsafe {
syscall_or_panic!(
libc::open(f.as_ptr(), libc::O_RDONLY, 0o644),
Expand All @@ -176,7 +176,7 @@ fn runit_child(sandbox: &Sandbox, runit_exists: bool) -> i32 {
unsafe { syscall_or_panic!(libc::dup2(fd, libc::STDIN_FILENO), "dup2 stdin") };
}
if let Some(file) = &sandbox.output {
let f = CString::new(file).unwrap();
let f = CString::new(file.clone()).unwrap();
let fd = unsafe {
syscall_or_panic!(
libc::open(f.as_ptr(), libc::O_CREAT | libc::O_RDWR, 0o644),
Expand All @@ -186,7 +186,7 @@ fn runit_child(sandbox: &Sandbox, runit_exists: bool) -> i32 {
unsafe { syscall_or_panic!(libc::dup2(fd, libc::STDOUT_FILENO), "dup2 stdout") };
}
if let Some(file) = &sandbox.error {
let f = CString::new(file).unwrap();
let f = CString::new(file.clone()).unwrap();
let fd = unsafe {
syscall_or_panic!(
libc::open(f.as_ptr(), libc::O_CREAT | libc::O_RDWR, 0o644),
Expand Down
3 changes: 2 additions & 1 deletion src/sys/linux/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ impl ExecArgs {
// env 传递环境变量
let mut envp_vec: Vec<*const libc::c_char> = vec![];
envp_vec.push(ptr::null());
let envs = envp_vec.len();
let envp = envp_vec.as_ptr() as *const *const libc::c_char;

mem::forget(pathname_str);
Expand All @@ -108,7 +109,7 @@ impl ExecArgs {
argv,
args: args.len(),
envp,
envs: envp_vec.len(),
envs,
})
}
}
Expand Down

0 comments on commit 05381f2

Please sign in to comment.