work on fixing login shell i/o issues

This commit is contained in:
2026-03-03 23:00:25 -05:00
parent 1795995b98
commit d5e0274114
2 changed files with 10 additions and 4 deletions

View File

@@ -115,7 +115,7 @@ fn main() -> ExitCode {
} else if let Some(cmd) = args.command {
exec_input(cmd, None, false, None)
} else {
shed_interactive()
shed_interactive(args)
} {
eprintln!("shed: {e}");
};
@@ -160,9 +160,9 @@ fn run_script<P: AsRef<Path>>(path: P, args: Vec<String>) -> ShResult<()> {
exec_input(input, None, false, Some(path_raw))
}
fn shed_interactive() -> ShResult<()> {
fn shed_interactive(args: ShedArgs) -> ShResult<()> {
let _raw_mode = raw_mode(); // sets raw mode, restores termios on drop
sig_setup();
sig_setup(args.login_shell);
if let Err(e) = source_rc() {
e.print_error();

View File

@@ -108,7 +108,7 @@ pub fn enable_reaping() {
REAPING_ENABLED.store(true, Ordering::SeqCst);
}
pub fn sig_setup() {
pub fn sig_setup(is_login: bool) {
let flags = SaFlags::empty();
let action = SigAction::new(SigHandler::Handler(handle_signal), flags, SigSet::empty());
@@ -147,6 +147,12 @@ pub fn sig_setup() {
sigaction(Signal::SIGPWR, &action).unwrap();
sigaction(Signal::SIGSYS, &action).unwrap();
}
if is_login {
setpgid(0, 0);
take_term().ok();
}
}
/// Reset all signal dispositions to SIG_DFL.