signal.rs 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. use core::mem;
  2. use super::{
  3. super::{types::*, PalSignal},
  4. e, Sys,
  5. };
  6. use crate::header::{
  7. signal::{sigaction, sigset_t, stack_t},
  8. sys_time::itimerval,
  9. };
  10. impl PalSignal for Sys {
  11. fn getitimer(which: c_int, out: *mut itimerval) -> c_int {
  12. // e(unsafe { syscall!(GETITIMER, which, out) }) as c_int
  13. unimplemented!()
  14. }
  15. fn kill(pid: pid_t, sig: c_int) -> c_int {
  16. e(unsafe { syscall!(SYS_KILL, pid, sig) }) as c_int
  17. }
  18. fn killpg(pgrp: pid_t, sig: c_int) -> c_int {
  19. e(unsafe { syscall!(SYS_KILL, -(pgrp as isize) as pid_t, sig) }) as c_int
  20. }
  21. fn raise(sig: c_int) -> c_int {
  22. let tid = e(unsafe { syscall!(SYS_GETPID) }) as pid_t;
  23. if tid == !0 {
  24. -1
  25. } else {
  26. // e(unsafe { syscall!(TKILL, tid, sig) }) as c_int
  27. Self::kill(tid, sig)
  28. }
  29. }
  30. fn setitimer(which: c_int, new: *const itimerval, old: *mut itimerval) -> c_int {
  31. // e(unsafe { syscall!(SETITIMER, which, new, old) }) as c_int
  32. unimplemented!()
  33. }
  34. fn sigaction(sig: c_int, act: Option<&sigaction>, oact: Option<&mut sigaction>) -> c_int {
  35. e(unsafe {
  36. syscall!(
  37. SYS_SIGACTION,
  38. sig,
  39. act.map_or_else(core::ptr::null, |x| x as *const _),
  40. oact.map_or_else(core::ptr::null_mut, |x| x as *mut _),
  41. mem::size_of::<sigset_t>()
  42. )
  43. }) as c_int
  44. }
  45. fn sigaltstack(ss: *const stack_t, old_ss: *mut stack_t) -> c_int {
  46. // e(unsafe { syscall!(SIGALTSTACK, ss, old_ss) }) as c_int
  47. unimplemented!()
  48. }
  49. fn sigprocmask(how: c_int, set: *const sigset_t, oset: *mut sigset_t) -> c_int {
  50. // e(unsafe { syscall!(RT_SIGPROCMASK, how, set, oset, mem::size_of::<sigset_t>()) }) as c_int
  51. unimplemented!()
  52. }
  53. }