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
Generated
+2 -2
View File
@@ -390,9 +390,9 @@ dependencies = [
[[package]]
name = "redox_syscall"
version = "0.5.4"
version = "0.5.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0884ad60e090bf1345b93da0a5de8923c93884cd03f40dfcfddd3b4bee661853"
checksum = "62871f2d65009c0256aed1b9cfeeb8ac272833c404e13d53d400cd0dad7a2ac0"
dependencies = [
"bitflags",
]
+1 -1
View File
@@ -59,7 +59,7 @@ features = ["c_api"]
sc = "0.2.3"
[target.'cfg(target_os = "redox")'.dependencies]
redox_syscall = "0.5.4"
redox_syscall = "0.5.5"
redox-rt = { path = "redox-rt" }
redox-path = "0.2"
redox_event = { git = "https://gitlab.redox-os.org/redox-os/event.git", default-features = false, features = ["redox_syscall"] }
+7
View File
@@ -44,6 +44,13 @@ pub fn posix_kill(pid: usize, sig: usize) -> Result<()> {
}
}
#[inline]
pub fn posix_sigqueue(pid: usize, sig: usize, val: usize) -> Result<()> {
match wrapper(false, || unsafe { syscall::syscall3(101, pid, sig, val) }) {
Ok(_) | Err(Error { errno: EINTR }) => Ok(()),
Err(error) => Err(error),
}
}
#[inline]
pub fn posix_killpg(pgrp: usize, sig: usize) -> Result<()> {
match wrapper(false, || syscall::kill(usize::wrapping_neg(pgrp), sig)) {
Ok(_) | Err(Error { errno: EINTR }) => Ok(()),
+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