work on fixing login shell i/o issues
This commit is contained in:
@@ -115,7 +115,7 @@ fn main() -> ExitCode {
|
|||||||
} else if let Some(cmd) = args.command {
|
} else if let Some(cmd) = args.command {
|
||||||
exec_input(cmd, None, false, None)
|
exec_input(cmd, None, false, None)
|
||||||
} else {
|
} else {
|
||||||
shed_interactive()
|
shed_interactive(args)
|
||||||
} {
|
} {
|
||||||
eprintln!("shed: {e}");
|
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))
|
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
|
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() {
|
if let Err(e) = source_rc() {
|
||||||
e.print_error();
|
e.print_error();
|
||||||
|
|||||||
@@ -108,7 +108,7 @@ pub fn enable_reaping() {
|
|||||||
REAPING_ENABLED.store(true, Ordering::SeqCst);
|
REAPING_ENABLED.store(true, Ordering::SeqCst);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn sig_setup() {
|
pub fn sig_setup(is_login: bool) {
|
||||||
let flags = SaFlags::empty();
|
let flags = SaFlags::empty();
|
||||||
|
|
||||||
let action = SigAction::new(SigHandler::Handler(handle_signal), flags, SigSet::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::SIGPWR, &action).unwrap();
|
||||||
sigaction(Signal::SIGSYS, &action).unwrap();
|
sigaction(Signal::SIGSYS, &action).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if is_login {
|
||||||
|
setpgid(Pid::from_raw(0), Pid::from_raw(0));
|
||||||
|
take_term().ok();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Reset all signal dispositions to SIG_DFL.
|
/// Reset all signal dispositions to SIG_DFL.
|
||||||
|
|||||||
Reference in New Issue
Block a user