diff options
Diffstat (limited to 'src/run/mod.rs')
| -rw-r--r-- | src/run/mod.rs | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/run/mod.rs b/src/run/mod.rs index e1dcacc..9e4ace8 100644 --- a/src/run/mod.rs +++ b/src/run/mod.rs @@ -31,8 +31,9 @@ pub fn run(se: &mut Session, cmd: Vec<u8>) { se.raw.disable(); - for (i, cmd) in pipes.cmds.iter().enumerate() { - let last = i == pipes.cmds.len() - 1; + let pipelen = pipes.cmds.len(); + for (i, cmd) in pipes.cmds.into_iter().enumerate() { + let last = i == pipelen - 1; let (reader, writer) = if !last { let (r, w) = io::pipe().unwrap(); @@ -87,12 +88,11 @@ pub fn run(se: &mut Session, cmd: Vec<u8>) { None => Box::new(io::stdout()), }; - // SAFETY: safe as long as we join all threads below again. - // panics were not considered so probably needs to be fixed - let args = &cmd.args; - let args: &'static Vec<BString> = unsafe { std::mem::transmute(args) }; - - let handle = std::thread::spawn(move || builtin.io(args, &mut input, &mut output)); + let handle = std::thread::spawn(move || { + let cmd = cmd; + let c = &cmd.args; + builtin.io(c, &mut input, &mut output) + }); threads.push(handle); } |
