From 36526f66a7fe33424fa289f0e7ccd88a77b018ef Mon Sep 17 00:00:00 2001 From: vasilito Date: Sat, 18 Jul 2026 10:26:46 +0900 Subject: [PATCH] login: temporary spawn diagnostics to pinpoint shell-start hang --- src/lib.rs | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index dc8b4353d9..e6c31d5f4a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -80,13 +80,27 @@ pub fn spawn_shell(user: &User) -> IoResult { // 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),