Remove obsolete proc usage, now reaches init.
This commit is contained in:
+1
-30
@@ -425,18 +425,6 @@ where
|
||||
deactivate_tcb(*open_via_dup)?;
|
||||
}
|
||||
|
||||
{
|
||||
let current_sigaction_fd = FdGuard::new(syscall::dup(*open_via_dup, b"sigactions")?);
|
||||
let empty_sigaction_fd = FdGuard::new(syscall::dup(*current_sigaction_fd, b"empty")?);
|
||||
let sigaction_selection_fd =
|
||||
FdGuard::new(syscall::dup(*open_via_dup, b"current-sigactions")?);
|
||||
|
||||
let _ = syscall::write(
|
||||
*sigaction_selection_fd,
|
||||
&usize::to_ne_bytes(*empty_sigaction_fd),
|
||||
)?;
|
||||
}
|
||||
|
||||
// TODO: Restore old name if exec failed?
|
||||
if let Ok(name_fd) = syscall::dup(*open_via_dup, b"name").map(FdGuard::new) {
|
||||
let _ = syscall::write(*name_fd, interp_override.as_ref().map_or(path, |o| &o.name));
|
||||
@@ -727,27 +715,10 @@ pub fn fork_inner(initial_rsp: *mut usize) -> Result<usize> {
|
||||
|
||||
// Reuse the same sigaltstack and signal entry (all memory will be re-mapped CoW later).
|
||||
{
|
||||
let cur_sighandler_fd = FdGuard::new(syscall::dup(*cur_pid_fd, b"sighandler")?);
|
||||
let new_sighandler_fd = FdGuard::new(syscall::dup(*new_pid_fd, b"sighandler")?);
|
||||
|
||||
let mut sighandler_buf = SetSighandlerData::default();
|
||||
|
||||
let _ = syscall::read(*cur_sighandler_fd, &mut sighandler_buf)?;
|
||||
let _ = syscall::write(*new_sighandler_fd, &sighandler_buf)?;
|
||||
let _ = syscall::write(*new_sighandler_fd, &crate::signal::current_setsighandler_struct())?;
|
||||
}
|
||||
|
||||
// Reuse the same sigactions (by value).
|
||||
{
|
||||
let cur_sigaction_fd = FdGuard::new(syscall::dup(*cur_pid_fd, b"sigactions")?);
|
||||
let new_sigaction_fd = FdGuard::new(syscall::dup(*cur_sigaction_fd, b"copy")?);
|
||||
let new_sigaction_sel_fd =
|
||||
FdGuard::new(syscall::dup(*new_pid_fd, b"current-sigactions")?);
|
||||
|
||||
let _ = syscall::write(
|
||||
*new_sigaction_sel_fd,
|
||||
&usize::to_ne_bytes(*new_sigaction_fd),
|
||||
)?;
|
||||
}
|
||||
copy_str(*cur_pid_fd, *new_pid_fd, "name")?;
|
||||
|
||||
// Copy existing files into new file table, but do not reuse the same file table (i.e. new
|
||||
|
||||
+10
-7
@@ -2,7 +2,7 @@ use core::cell::Cell;
|
||||
use core::ffi::c_int;
|
||||
use core::sync::atomic::{AtomicU64, Ordering};
|
||||
|
||||
use syscall::{Error, IntRegisters, Result, SigProcControl, Sigcontrol, EINVAL, SIGCHLD, SIGCONT, SIGKILL, SIGSTOP, SIGTSTP, SIGTTIN, SIGTTOU, SIGURG, SIGW0_TSTP_IS_STOP_BIT, SIGW0_TTIN_IS_STOP_BIT, SIGW0_TTOU_IS_STOP_BIT, SIGWINCH};
|
||||
use syscall::{Error, IntRegisters, Result, SetSighandlerData, SigProcControl, Sigcontrol, EINVAL, SIGCHLD, SIGCONT, SIGKILL, SIGSTOP, SIGTSTP, SIGTTIN, SIGTTOU, SIGURG, SIGW0_TSTP_IS_STOP_BIT, SIGW0_TTIN_IS_STOP_BIT, SIGW0_TTOU_IS_STOP_BIT, SIGWINCH};
|
||||
|
||||
use crate::{arch::*, Tcb};
|
||||
use crate::sync::Mutex;
|
||||
@@ -260,12 +260,7 @@ pub fn setup_sighandler(control: &Sigcontrol) {
|
||||
CPUID_EAX1_ECX.store(cpuid_eax1_ecx, core::sync::atomic::Ordering::Relaxed);
|
||||
}
|
||||
|
||||
let data = syscall::SetSighandlerData {
|
||||
user_handler: sighandler_function(),
|
||||
excp_handler: 0, // TODO
|
||||
thread_control_addr: control as *const Sigcontrol as usize,
|
||||
proc_control_addr: &PROC_CONTROL_STRUCT as *const SigProcControl as usize,
|
||||
};
|
||||
let data = current_setsighandler_struct();
|
||||
|
||||
let fd = syscall::open(
|
||||
"thisproc:current/sighandler",
|
||||
@@ -280,3 +275,11 @@ pub struct RtSigarea {
|
||||
pub control: Sigcontrol,
|
||||
pub arch: crate::arch::SigArea,
|
||||
}
|
||||
pub fn current_setsighandler_struct() -> SetSighandlerData {
|
||||
SetSighandlerData {
|
||||
user_handler: sighandler_function(),
|
||||
excp_handler: 0, // TODO
|
||||
thread_control_addr: core::ptr::addr_of!(unsafe { Tcb::current() }.unwrap().os_specific.control) as usize,
|
||||
proc_control_addr: &PROC_CONTROL_STRUCT as *const SigProcControl as usize,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user