Merge branch 'legacy-spawn' into 'main'
daemon: Fix boot stuck in pcid spawning drivers See merge request redox-os/base!250
This commit is contained in:
+5
-4
@@ -21,12 +21,12 @@ unsafe fn get_fd(var: &str) -> RawFd {
|
||||
fd
|
||||
}
|
||||
|
||||
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(())
|
||||
@@ -60,13 +60,14 @@ impl Daemon {
|
||||
pub fn spawn(mut cmd: Command) {
|
||||
let (mut read_pipe, write_pipe) = io::pipe().unwrap();
|
||||
|
||||
unsafe { pass_fd(&mut cmd, "INIT_NOTIFY", write_pipe.into()) };
|
||||
unsafe { pass_fd(&mut cmd, "INIT_NOTIFY", write_pipe.as_raw_fd()) };
|
||||
|
||||
if let Err(err) = cmd.spawn() {
|
||||
eprintln!("daemon: failed to execute {cmd:?}: {err}");
|
||||
return;
|
||||
}
|
||||
|
||||
drop(write_pipe);
|
||||
let mut data = [0];
|
||||
match read_pipe.read_exact(&mut data) {
|
||||
Ok(()) => {}
|
||||
|
||||
Reference in New Issue
Block a user