diff --git a/redox-rt/src/proc.rs b/redox-rt/src/proc.rs index 216f282e5b..a58c9bf064 100644 --- a/redox-rt/src/proc.rs +++ b/redox-rt/src/proc.rs @@ -918,7 +918,7 @@ pub fn copy_str(cur_pid_fd: usize, new_proc_fd: usize, key: &str) -> Result<()> Ok(()) } -pub unsafe fn make_init() -> &'static FdGuard { +pub unsafe fn make_init() -> [&'static FdGuard; 2] { let proc_fd = FdGuard::new( syscall::open("/scheme/proc/init", syscall::O_CLOEXEC).expect("failed to create init"), ); @@ -930,6 +930,12 @@ pub unsafe fn make_init() -> &'static FdGuard { ) .expect("failed to assign current thread to init process"); + let managed_thr_fd = FdGuard::new( + syscall::dup(*proc_fd, b"thread-0").expect("failed to get managed thread for init"), + ); + + let managed_thr_fd = (*RtTcb::current().thr_fd.get()).insert(managed_thr_fd); + STATIC_PROC_INFO.get().write(crate::StaticProcInfo { pid: 1, ppid: 1, @@ -944,5 +950,8 @@ pub unsafe fn make_init() -> &'static FdGuard { egid: 0, sgid: 0, }; - (*STATIC_PROC_INFO.get()).proc_fd.as_ref().unwrap() + [ + (*STATIC_PROC_INFO.get()).proc_fd.as_ref().unwrap(), + managed_thr_fd, + ] }