From 5f62c305395596c78b504f1219c7d7d65ad73ed4 Mon Sep 17 00:00:00 2001
From: 4lDO2 <4lDO2@protonmail.com>
Date: Sat, 20 Jul 2024 22:18:25 +0200
Subject: [PATCH] Update aarch64's child_hook.

---
 redox-rt/src/arch/aarch64.rs | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/redox-rt/src/arch/aarch64.rs b/redox-rt/src/arch/aarch64.rs
index c9aaccbf..02ac5341 100644
--- a/redox-rt/src/arch/aarch64.rs
+++ b/redox-rt/src/arch/aarch64.rs
@@ -5,7 +5,7 @@ use syscall::{data::*, error::*};
 use crate::{
     proc::{fork_inner, FdGuard},
     signal::{inner_c, RtSigarea, SigStack, PROC_CONTROL_STRUCT},
-    Tcb,
+    RtTcb, Tcb,
 };
 
 // Setup a stack starting from the very end of the address space, and then growing downwards.
@@ -99,7 +99,11 @@ unsafe extern "C" fn fork_impl(initial_rsp: *mut usize) -> usize {
 
 unsafe extern "C" fn child_hook(cur_filetable_fd: usize, new_pid_fd: usize) {
     let _ = syscall::close(cur_filetable_fd);
-    let _ = syscall::close(new_pid_fd);
+    // TODO: Currently pidfd == threadfd, but this will not be the case later.
+    RtTcb::current()
+        .thr_fd
+        .get()
+        .write(Some(FdGuard::new(new_pid_fd)));
 }
 
 asmfunction!(__relibc_internal_fork_wrapper -> usize: ["
-- 
GitLab