Merge branch 'init-stuck' into 'main'

init: Fix boot stuck caused by driver exiting

See merge request redox-os/base!249
This commit is contained in:
Jeremy Soller
2026-04-28 09:07:19 -06:00
2 changed files with 14 additions and 13 deletions
+8 -8
View File
@@ -121,11 +121,11 @@ install-base: base $(SYSROOT)/bin/redoxfs
# Device file symlinks
@mkdir -pv "$(DESTDIR)/dev"
ln -s /scheme/null $(DESTDIR)/dev/null
ln -s /scheme/rand $(DESTDIR)/dev/random
ln -s /scheme/rand $(DESTDIR)/dev/urandom
ln -s /scheme/zero $(DESTDIR)/dev/zero
ln -s libc:tty $(DESTDIR)/dev/tty
ln -s libc:stdin $(DESTDIR)/dev/stdin
ln -s libc:stdout $(DESTDIR)/dev/stdout
ln -s libc:stderr $(DESTDIR)/dev/stderr
ln -sf /scheme/null $(DESTDIR)/dev/null
ln -sf /scheme/rand $(DESTDIR)/dev/random
ln -sf /scheme/rand $(DESTDIR)/dev/urandom
ln -sf /scheme/zero $(DESTDIR)/dev/zero
ln -sf libc:tty $(DESTDIR)/dev/tty
ln -sf libc:stdin $(DESTDIR)/dev/stdin
ln -sf libc:stdout $(DESTDIR)/dev/stdout
ln -sf libc:stderr $(DESTDIR)/dev/stderr
+6 -5
View File
@@ -1,7 +1,7 @@
use std::collections::{BTreeMap, BTreeSet};
use std::ffi::OsString;
use std::io::Read;
use std::os::fd::{AsRawFd, OwnedFd};
use std::os::fd::{AsRawFd, RawFd};
use std::os::unix::process::CommandExt;
use std::process::Command;
use std::{env, io};
@@ -47,7 +47,7 @@ impl Service {
command.envs(base_envs).envs(&self.envs);
let (mut read_pipe, write_pipe) = io::pipe().unwrap();
unsafe { pass_fd(&mut command, "INIT_NOTIFY", write_pipe.into()) };
unsafe { pass_fd(&mut command, "INIT_NOTIFY", write_pipe.as_raw_fd()) };
let mut child = match command.spawn() {
Ok(child) => child,
@@ -56,6 +56,7 @@ impl Service {
return;
}
};
drop(write_pipe);
match &self.type_ {
ServiceType::Notify => match read_pipe.read_exact(&mut [0]) {
@@ -117,12 +118,12 @@ impl Service {
}
}
unsafe fn pass_fd(cmd: &mut Command, env: &str, fd: OwnedFd) {
cmd.env(env, format!("{}", fd.as_raw_fd()));
unsafe fn pass_fd(cmd: &mut Command, env: &str, fd: RawFd) {
cmd.env(env, format!("{}", fd));
unsafe {
cmd.pre_exec(move || {
// Pass notify pipe to child
if libc::fcntl(fd.as_raw_fd(), libc::F_SETFD, 0) == -1 {
if libc::fcntl(fd, libc::F_SETFD, 0) == -1 {
Err(io::Error::last_os_error())
} else {
Ok(())