Respect user-defined exit signal in clone() and clone3()

When calling clone() and clone3(), the user is allowed to specify a
signal to be sent to the parent process on exit. Respect this value by
storing it in the Process struct and sending the signal on exit.

Add a test as well to verify that the signal is properly delivered to
the parent.
This commit is contained in:
Carlos López
2024-09-24 21:33:10 +02:00
committed by Tate, Hongliang Tian
parent 130a0f7030
commit 0a36760f7a
7 changed files with 122 additions and 14 deletions

View File

@ -7,11 +7,7 @@ use ostd::cpu::UserContext;
use super::SyscallReturn;
use crate::{
prelude::*,
process::{
clone_child,
signal::{constants::SIGCHLD, sig_num::SigNum},
CloneArgs, CloneFlags,
},
process::{clone_child, signal::sig_num::SigNum, CloneArgs, CloneFlags},
};
// The order of arguments for clone differs in different architecture.
@ -87,11 +83,7 @@ struct Clone3Args {
impl From<Clone3Args> for CloneArgs {
fn from(value: Clone3Args) -> Self {
// TODO: deal with pidfd, exit_signal, set_tid, set_tid_size, cgroup
if value.exit_signal != 0 || value.exit_signal as u8 != SIGCHLD.as_u8() {
warn!("exit signal is not supported");
}
// TODO: deal with pidfd, set_tid, set_tid_size, cgroup
if value.pidfd != 0 {
warn!("pidfd is not supported");
}