re-imported job/signal code from old implementation

This commit is contained in:
2025-03-15 17:14:52 -04:00
parent 2acf70ef96
commit d4f8f023af
15 changed files with 494 additions and 35 deletions

View File

@@ -1,4 +1,4 @@
use std::{fmt::Display, ops::Range, str::FromStr};
use std::{fmt::Display, ops::Range};
use crate::{parse::lex::Span, prelude::*};

View File

@@ -1,3 +1,4 @@
pub mod error;
pub mod term;
pub mod flog;
pub mod sys;

18
src/libsh/sys.rs Normal file
View File

@@ -0,0 +1,18 @@
use crate::{prelude::*, state::write_jobs};
pub fn sh_quit(code: i32) -> ! {
write_jobs(|j| {
for job in j.jobs_mut().iter_mut().flatten() {
job.killpg(Signal::SIGTERM).ok();
}
});
if let Some(termios) = crate::get_saved_termios() {
termios::tcsetattr(std::io::stdin(), termios::SetArg::TCSANOW, &termios).unwrap();
}
if code == 0 {
eprintln!("exit");
} else {
eprintln!("exit {code}");
}
exit(code);
}