login: temporary spawn diagnostics to pinpoint shell-start hang

This commit is contained in:
2026-07-18 10:26:46 +09:00
parent 0a1c31fd18
commit 36526f66a7
+18 -4
View File
@@ -80,13 +80,27 @@ pub fn spawn_shell<T: Default>(user: &User<T>) -> IoResult<i32> {
// the CWD fd (including the child's exec) then hang. Point the CWD at the
// user's home (falling back to `/`), both of which live on the `file`
// scheme that is always present in the login namespace.
if std::env::set_current_dir(&user.home).is_err() {
let _ = std::env::set_current_dir("/");
}
let chdir_ok = std::env::set_current_dir(&user.home).is_ok()
|| std::env::set_current_dir("/").is_ok();
eprintln!(
"spawn-diag: chdir_ok={} cwd={:?}; about to spawn {:?}",
chdir_ok,
std::env::current_dir().ok(),
user.shell
);
let mut command = user.shell_cmd();
let mut child = command.spawn()?;
let mut child = match command.spawn() {
Ok(c) => {
eprintln!("spawn-diag: command.spawn() returned Ok (child created)");
c
}
Err(e) => {
eprintln!("spawn-diag: command.spawn() FAILED: {} ({:?})", e, e.raw_os_error());
return Err(e);
}
};
match child.wait()?.code() {
Some(code) => Ok(code),
None => Ok(1),