DIAG: log service spawn/wait; temporarily revert switch_root chdir to test spawn hang
This commit is contained in:
+3
-15
@@ -54,21 +54,9 @@ impl InitConfig {
|
|||||||
fn switch_root(unit_store: &mut UnitStore, config: &mut InitConfig, prefix: &Path, etcdir: &Path) {
|
fn switch_root(unit_store: &mut UnitStore, config: &mut InitConfig, prefix: &Path, etcdir: &Path) {
|
||||||
status_ok(&format!("switchroot to {} {}", prefix.display(), etcdir.display()));
|
status_ok(&format!("switchroot to {} {}", prefix.display(), etcdir.display()));
|
||||||
|
|
||||||
// Point init's working directory at a valid directory in the new root so
|
// DIAGNOSTIC: chdir temporarily removed to test whether it was causing the
|
||||||
// daemons spawned afterwards don't inherit an invalid CWD (via
|
// first /usr Command::spawn() to hang (relibc posix_spawn opens the cwd
|
||||||
// AT_REDOX_CWD_FD). Without this, getcwd() fails in /usr binaries — e.g.
|
// fd). Re-add a correct CWD fix once the spawn hang is understood.
|
||||||
// the 00_base-env `zsh -c` setup printed "zsh: Failed to get current
|
|
||||||
// directory: path invalid" and then hung, so init (which waits on that
|
|
||||||
// oneshot) never reached the login stack. The switch is logical (no
|
|
||||||
// chroot) and `prefix` (e.g. "/usr") is not itself a directory, so try the
|
|
||||||
// plausible roots in order and keep the first that works.
|
|
||||||
let cwd_candidates = [prefix.to_path_buf(), std::path::PathBuf::from("/")];
|
|
||||||
if !cwd_candidates
|
|
||||||
.iter()
|
|
||||||
.any(|cand| std::env::set_current_dir(cand).is_ok())
|
|
||||||
{
|
|
||||||
init_warn("failed to establish a valid working directory after switch_root");
|
|
||||||
}
|
|
||||||
|
|
||||||
config
|
config
|
||||||
.envs
|
.envs
|
||||||
|
|||||||
@@ -70,6 +70,8 @@ impl Service {
|
|||||||
.unwrap_or_else(|e| panic!("pipe() failed in service.spawn for {}: {}", self.cmd, e));
|
.unwrap_or_else(|e| panic!("pipe() failed in service.spawn for {}: {}", self.cmd, e));
|
||||||
unsafe { pass_fd(&mut command, "INIT_NOTIFY", write_pipe.into()) };
|
unsafe { pass_fd(&mut command, "INIT_NOTIFY", write_pipe.into()) };
|
||||||
|
|
||||||
|
eprintln!("init-diag: SPAWNING {}", self.cmd);
|
||||||
|
let _ = io::stderr().flush();
|
||||||
let mut child = match command.spawn() {
|
let mut child = match command.spawn() {
|
||||||
Ok(child) => child,
|
Ok(child) => child,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
@@ -77,6 +79,8 @@ impl Service {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
eprintln!("init-diag: SPAWNED {} (type {:?})", self.cmd, self.type_);
|
||||||
|
let _ = io::stderr().flush();
|
||||||
|
|
||||||
match &self.type_ {
|
match &self.type_ {
|
||||||
ServiceType::Notify => {
|
ServiceType::Notify => {
|
||||||
@@ -126,6 +130,8 @@ impl Service {
|
|||||||
}
|
}
|
||||||
ServiceType::Oneshot => {
|
ServiceType::Oneshot => {
|
||||||
drop(read_pipe);
|
drop(read_pipe);
|
||||||
|
eprintln!("init-diag: WAITING {}", self.cmd);
|
||||||
|
let _ = io::stderr().flush();
|
||||||
match child.wait() {
|
match child.wait() {
|
||||||
Ok(exit_status) => {
|
Ok(exit_status) => {
|
||||||
if !exit_status.success() {
|
if !exit_status.success() {
|
||||||
|
|||||||
Reference in New Issue
Block a user