WIP: implement sigqueue

This commit is contained in:
4lDO2
2024-07-25 19:28:10 +02:00
parent 1e97bae11b
commit 75b2dcaa45
6 changed files with 33 additions and 6 deletions
+11
View File
@@ -67,6 +67,11 @@ pub struct siginfo {
#[no_mangle]
pub extern "C" fn _cbindgen_export_siginfo(a: siginfo) {}
pub union sigval {
pub si_int: c_int,
pub si_ptr: *mut c_void,
}
/// cbindgen:ignore
pub type sigset_t = c_ulonglong;
/// cbindgen:ignore
@@ -78,6 +83,12 @@ pub type stack_t = sigaltstack;
pub extern "C" fn kill(pid: pid_t, sig: c_int) -> c_int {
Sys::kill(pid, sig)
}
#[no_mangle]
pub extern "C" fn sigqueue(pid: pid_t, sig: c_int, val: sigval) -> c_int {
Sys::sigqueue(pid, sig, val)
.map(|()| 0)
.or_minus_one_errno()
}
#[no_mangle]
pub extern "C" fn killpg(pgrp: pid_t, sig: c_int) -> c_int {
+3 -1
View File
@@ -2,7 +2,7 @@ use super::super::{types::*, Pal};
use crate::{
error::Errno,
header::{
signal::{sigaction, siginfo_t, sigset_t, stack_t},
signal::{sigaction, siginfo_t, sigset_t, sigval, stack_t},
sys_time::itimerval,
time::timespec,
},
@@ -13,6 +13,8 @@ pub trait PalSignal: Pal {
fn kill(pid: pid_t, sig: c_int) -> c_int;
fn sigqueue(pid: pid_t, sig: c_int, val: sigval) -> Result<(), Errno>;
fn killpg(pgrp: pid_t, sig: c_int) -> c_int;
fn raise(sig: c_int) -> Result<(), Errno>;
+9 -2
View File
@@ -11,8 +11,8 @@ use crate::{
header::{
errno::{EINVAL, ENOSYS},
signal::{
sigaction, siginfo_t, sigset_t, stack_t, SA_SIGINFO, SIG_BLOCK, SIG_DFL, SIG_IGN,
SIG_SETMASK, SIG_UNBLOCK, SS_DISABLE, SS_ONSTACK,
sigaction, siginfo_t, sigset_t, sigval, stack_t, SA_SIGINFO, SIG_BLOCK, SIG_DFL,
SIG_IGN, SIG_SETMASK, SIG_UNBLOCK, SS_DISABLE, SS_ONSTACK,
},
sys_time::{itimerval, ITIMER_REAL},
time::timespec,
@@ -55,6 +55,13 @@ impl PalSignal for Sys {
fn kill(pid: pid_t, sig: c_int) -> c_int {
e(redox_rt::sys::posix_kill(pid as usize, sig as usize).map(|()| 0)) as c_int
}
fn sigqueue(pid: pid_t, sig: c_int, val: sigval) -> Result<(), Errno> {
Ok(redox_rt::sys::posix_sigqueue(
pid as usize,
sig as usize,
unsafe { val.si_ptr } as usize,
)?)
}
fn killpg(pgrp: pid_t, sig: c_int) -> c_int {
e(redox_rt::sys::posix_killpg(pgrp as usize, sig as usize).map(|()| 0)) as c_int