diff --git a/src/lib/shell/mod.rs b/src/lib/shell/mod.rs index 1ca66d6da52d0a9d965d4e4aa2435cbd506577ed..3a7522e80e2dc8f6c562b441bebd56cd76c7ad12 100644 --- a/src/lib/shell/mod.rs +++ b/src/lib/shell/mod.rs @@ -84,9 +84,6 @@ pub struct Shell { pub(crate) previous_job: u32, /// Contains all the boolean flags that control shell behavior. pub flags: u8, - /// A temporary field for storing foreground PIDs used by the pipeline - /// execution. - foreground: Vec<u32>, /// Contains information on all of the active background processes that are being managed /// by the shell. pub(crate) background: Arc<Mutex<Vec<BackgroundProcess>>>, @@ -170,7 +167,6 @@ impl<'a> Shell { previous_job: !0, previous_status: 0, flags: 0, - foreground: Vec::new(), background: Arc::new(Mutex::new(Vec::new())), is_background_shell: false, is_library, diff --git a/src/lib/shell/pipe_exec/job_control.rs b/src/lib/shell/pipe_exec/job_control.rs index 854fd97a1c15fd046996fde25cf88ec7007adc8c..5fcd3d086b3c2cf433b78d7985e0aee2926e7079 100644 --- a/src/lib/shell/pipe_exec/job_control.rs +++ b/src/lib/shell/pipe_exec/job_control.rs @@ -31,7 +31,6 @@ pub(crate) trait JobControl { fn set_bg_task_in_foreground(&self, pid: u32, cont: bool) -> i32; fn resume_stopped(&mut self); fn handle_signal(&self, signal: i32) -> bool; - fn foreground_send(&self, signal: i32); fn background_send(&self, signal: i32); fn watch_foreground(&mut self, pid: i32, command: &str) -> i32; fn send_to_background(&mut self, child: u32, state: ProcessState, command: String); @@ -152,13 +151,6 @@ impl JobControl for Shell { self_sys::watch_foreground(self, pid, command) } - /// Send a kill signal to all running foreground tasks. - fn foreground_send(&self, signal: i32) { - for &process in self.foreground.iter() { - let _ = sys::killpg(process, signal); - } - } - /// Resumes all stopped background jobs fn resume_stopped(&mut self) { for process in self.background.lock().unwrap().iter() { diff --git a/src/lib/shell/pipe_exec/mod.rs b/src/lib/shell/pipe_exec/mod.rs index 087b9637686a9e0192dd23490c29a471eca9042d..36c52326fc03a49516677cd650a53a21d1d43d65 100644 --- a/src/lib/shell/pipe_exec/mod.rs +++ b/src/lib/shell/pipe_exec/mod.rs @@ -414,8 +414,6 @@ pub(crate) trait PipelineExecution { impl PipelineExecution for Shell { fn execute_pipeline(&mut self, pipeline: &mut Pipeline) -> i32 { - // Remove any leftover foreground tasks from the last execution. - self.foreground.clear(); // If the supplied pipeline is a background, a string representing the command // and a boolean representing whether it should be disowned is stored here. let possible_background_name = @@ -1002,7 +1000,6 @@ fn spawn_proc( close(stdin); close(stdout); close(stderr); - shell.foreground.push(pid); *last_pid = *current_pid; *current_pid = pid; }, @@ -1025,7 +1022,6 @@ fn spawn_proc( Ok(pid) => { close(stdout); close(stderr); - shell.foreground.push(pid); *last_pid = *current_pid; *current_pid = pid; }, @@ -1048,7 +1044,6 @@ fn spawn_proc( Ok(pid) => { close(stdout); close(stderr); - shell.foreground.push(pid); *last_pid = *current_pid; *current_pid = pid; }, @@ -1069,7 +1064,6 @@ fn spawn_proc( } Ok(pid) => { close(stdout); - shell.foreground.push(pid); *last_pid = *current_pid; *current_pid = pid; } @@ -1090,7 +1084,6 @@ fn spawn_proc( Ok(pid) => { close(stdout); close(stderr); - shell.foreground.push(pid); *last_pid = *current_pid; *current_pid = pid; } diff --git a/src/lib/sys/redox.rs b/src/lib/sys/redox.rs index 1b19fd5ace7a561e22768f88468cf5cb013a68e8..3889d783652d9c5a5a071fc206d5f40db66d3d86 100644 --- a/src/lib/sys/redox.rs +++ b/src/lib/sys/redox.rs @@ -234,9 +234,11 @@ pub mod job_control { } } + let pid = get_pid_value(pid); + loop { status = 0; - let result = waitpid(get_pid_value(pid), &mut status, 0); + let result = waitpid(pid, &mut status, 0); match result { Err(error) => { match error.errno { @@ -257,7 +259,7 @@ pub mod job_control { eprintln!("ion: process ended by signal {}", signal); match signal { SIGINT => { - shell.foreground_send(signal as i32); + let _ = syscall::kill(pid, signal as usize); shell.break_flow = true; } _ => { diff --git a/src/lib/sys/unix/job_control.rs b/src/lib/sys/unix/job_control.rs index 3343fa6f9af780e5f2b10f348b66bcfc17125348..fdfc879e9bd1c816e732e4d53e631061cbc1650e 100644 --- a/src/lib/sys/unix/job_control.rs +++ b/src/lib/sys/unix/job_control.rs @@ -6,7 +6,6 @@ use shell::status::{FAILURE, TERMINATED}; use std::sync::{Arc, Mutex}; use std::thread::sleep; use std::time::Duration; -use std::io; use super::{errno, write_errno}; pub(crate) fn watch_background( @@ -108,7 +107,7 @@ pub(crate) fn watch_foreground(shell: &mut Shell, pid: i32, command: &str) -> i3 eprintln!("ion: process ended by signal {}", signal); match signal { SIGINT => { - shell.foreground_send(signal as i32); + let _ = kill(pid, signal as i32); shell.break_flow = true; } _ => {