mirror of
https://github.com/asterinas/asterinas.git
synced 2025-06-22 00:43:24 +00:00
Remove the shim kernel crate
This commit is contained in:
committed by
Tate, Hongliang Tian
parent
d76c7a5b1e
commit
dafd16075f
33
kernel/src/syscall/tgkill.rs
Normal file
33
kernel/src/syscall/tgkill.rs
Normal file
@ -0,0 +1,33 @@
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
use super::SyscallReturn;
|
||||
use crate::{
|
||||
prelude::*,
|
||||
process::{
|
||||
signal::{
|
||||
sig_num::SigNum,
|
||||
signals::user::{UserSignal, UserSignalKind},
|
||||
},
|
||||
tgkill, Pid,
|
||||
},
|
||||
thread::Tid,
|
||||
};
|
||||
|
||||
/// tgkill send a signal to a thread with pid as its thread id, and tgid as its thread group id.
|
||||
pub fn sys_tgkill(tgid: Pid, tid: Tid, sig_num: u8, ctx: &Context) -> Result<SyscallReturn> {
|
||||
let sig_num = if sig_num == 0 {
|
||||
None
|
||||
} else {
|
||||
Some(SigNum::try_from(sig_num)?)
|
||||
};
|
||||
|
||||
debug!("tgid = {}, pid = {}, sig_num = {:?}", tgid, tid, sig_num);
|
||||
|
||||
let signal = sig_num.map(|sig_num| {
|
||||
let pid = ctx.process.pid();
|
||||
let uid = ctx.posix_thread.credentials().ruid();
|
||||
UserSignal::new(sig_num, UserSignalKind::Tkill, pid, uid)
|
||||
});
|
||||
tgkill(tid, tgid, signal)?;
|
||||
Ok(SyscallReturn::Return(0))
|
||||
}
|
Reference in New Issue
Block a user