Ran the codebase through rustfmt
This commit is contained in:
92
src/jobs.rs
92
src/jobs.rs
@@ -4,7 +4,7 @@ use crate::{
|
||||
term::{Style, Styled},
|
||||
},
|
||||
prelude::*,
|
||||
procio::{IoMode, borrow_fd},
|
||||
procio::{borrow_fd, IoMode},
|
||||
signal::{disable_reaping, enable_reaping},
|
||||
state::{self, read_jobs, set_status, write_jobs},
|
||||
};
|
||||
@@ -384,40 +384,40 @@ impl JobTab {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn hang_up(&mut self) {
|
||||
for job in self.jobs_mut().iter_mut().flatten() {
|
||||
if job.send_hup {
|
||||
job.killpg(Signal::SIGHUP).ok();
|
||||
}
|
||||
}
|
||||
}
|
||||
pub fn hang_up(&mut self) {
|
||||
for job in self.jobs_mut().iter_mut().flatten() {
|
||||
if job.send_hup {
|
||||
job.killpg(Signal::SIGHUP).ok();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn disown(&mut self, id: JobID, nohup: bool) -> ShResult<()> {
|
||||
if let Some(job) = self.query_mut(id.clone()) {
|
||||
if nohup {
|
||||
job.no_hup();
|
||||
} else {
|
||||
self.remove_job(id);
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
pub fn disown(&mut self, id: JobID, nohup: bool) -> ShResult<()> {
|
||||
if let Some(job) = self.query_mut(id.clone()) {
|
||||
if nohup {
|
||||
job.no_hup();
|
||||
} else {
|
||||
self.remove_job(id);
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn disown_all(&mut self, nohup: bool) -> ShResult<()> {
|
||||
let mut ids_to_remove = vec![];
|
||||
for job in self.jobs_mut().iter_mut().flatten() {
|
||||
if nohup {
|
||||
job.no_hup();
|
||||
} else {
|
||||
ids_to_remove.push(JobID::TableID(job.tabid().unwrap()));
|
||||
}
|
||||
}
|
||||
pub fn disown_all(&mut self, nohup: bool) -> ShResult<()> {
|
||||
let mut ids_to_remove = vec![];
|
||||
for job in self.jobs_mut().iter_mut().flatten() {
|
||||
if nohup {
|
||||
job.no_hup();
|
||||
} else {
|
||||
ids_to_remove.push(JobID::TableID(job.tabid().unwrap()));
|
||||
}
|
||||
}
|
||||
|
||||
for id in ids_to_remove {
|
||||
self.remove_job(id);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
for id in ids_to_remove {
|
||||
self.remove_job(id);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
@@ -425,7 +425,7 @@ pub struct JobBldr {
|
||||
table_id: Option<usize>,
|
||||
pgid: Option<Pid>,
|
||||
children: Vec<ChildProc>,
|
||||
send_hup: bool,
|
||||
send_hup: bool,
|
||||
}
|
||||
|
||||
impl Default for JobBldr {
|
||||
@@ -440,7 +440,7 @@ impl JobBldr {
|
||||
table_id: None,
|
||||
pgid: None,
|
||||
children: vec![],
|
||||
send_hup: true,
|
||||
send_hup: true,
|
||||
}
|
||||
}
|
||||
pub fn with_id(self, id: usize) -> Self {
|
||||
@@ -448,7 +448,7 @@ impl JobBldr {
|
||||
table_id: Some(id),
|
||||
pgid: self.pgid,
|
||||
children: self.children,
|
||||
send_hup: self.send_hup,
|
||||
send_hup: self.send_hup,
|
||||
}
|
||||
}
|
||||
pub fn with_pgid(self, pgid: Pid) -> Self {
|
||||
@@ -456,7 +456,7 @@ impl JobBldr {
|
||||
table_id: self.table_id,
|
||||
pgid: Some(pgid),
|
||||
children: self.children,
|
||||
send_hup: self.send_hup,
|
||||
send_hup: self.send_hup,
|
||||
}
|
||||
}
|
||||
pub fn set_pgid(&mut self, pgid: Pid) {
|
||||
@@ -465,16 +465,16 @@ impl JobBldr {
|
||||
pub fn pgid(&self) -> Option<Pid> {
|
||||
self.pgid
|
||||
}
|
||||
pub fn no_hup(mut self) -> Self {
|
||||
self.send_hup = false;
|
||||
self
|
||||
}
|
||||
pub fn no_hup(mut self) -> Self {
|
||||
self.send_hup = false;
|
||||
self
|
||||
}
|
||||
pub fn with_children(self, children: Vec<ChildProc>) -> Self {
|
||||
Self {
|
||||
table_id: self.table_id,
|
||||
pgid: self.pgid,
|
||||
children,
|
||||
send_hup: self.send_hup,
|
||||
send_hup: self.send_hup,
|
||||
}
|
||||
}
|
||||
pub fn push_child(&mut self, child: ChildProc) {
|
||||
@@ -485,7 +485,7 @@ impl JobBldr {
|
||||
table_id: self.table_id,
|
||||
pgid: self.pgid.unwrap_or(Pid::from_raw(0)),
|
||||
children: self.children,
|
||||
send_hup: self.send_hup,
|
||||
send_hup: self.send_hup,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -514,16 +514,16 @@ pub struct Job {
|
||||
table_id: Option<usize>,
|
||||
pgid: Pid,
|
||||
children: Vec<ChildProc>,
|
||||
send_hup: bool,
|
||||
send_hup: bool,
|
||||
}
|
||||
|
||||
impl Job {
|
||||
pub fn set_tabid(&mut self, id: usize) {
|
||||
self.table_id = Some(id)
|
||||
}
|
||||
pub fn no_hup(&mut self) {
|
||||
self.send_hup = false;
|
||||
}
|
||||
pub fn no_hup(&mut self) {
|
||||
self.send_hup = false;
|
||||
}
|
||||
pub fn running(&self) -> bool {
|
||||
!self.children.iter().all(|chld| chld.exited())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user