Lines Matching refs:signal
17 #[cfg(any(feature = "aio", feature = "signal"))]
20 #[cfg(any(feature = "aio", feature = "process", feature = "signal"))]
24 // type for signal constants.
29 #[cfg_attr(docsrs, doc(cfg(any(feature = "aio", feature = "signal"))))]
49 /// User defined signal 1
53 /// User defined signal 2
59 /// Software termination signal from kill
71 /// Sendable stop signal not from tty
73 /// Stop signal from tty
91 /// Input/output possible signal
118 #[cfg(feature = "signal")]
197 #[cfg(feature = "signal")]
199 /// Returns name of signal.
279 #[cfg(feature = "signal")]
286 #[cfg(feature = "signal")]
293 #[cfg(feature = "signal")]
297 #[cfg(feature = "signal")]
305 #[cfg(feature = "signal")]
325 #[cfg(feature = "signal")]
341 #[cfg(feature = "signal")]
356 #[cfg(feature = "signal")]
365 #![feature = "signal"]
413 #[cfg(feature = "signal")]
416 #[cfg_attr(docsrs, doc(cfg(feature = "signal")))]
418 /// When catching a [`Signal::SIGCHLD`] signal, the signal will be
422 /// When catching a [`Signal::SIGCHLD`] signal, the system will not
425 /// Further occurrences of the delivered signal are not masked during
428 /// The system will deliver the signal to the process on a signal stack,
431 /// The handler is reset back to the default at the moment the signal is
435 /// signal. See the man page for complete details.
442 #[cfg(feature = "signal")]
444 /// Specifies how certain functions should manipulate a signal mask
447 #[cfg_attr(docsrs, doc(cfg(feature = "signal")))]
460 #![feature = "signal"]
495 /// Add the specified signal to the set.
497 pub fn add(&mut self, signal: Signal) {
498 unsafe { libc::sigaddset(&mut self.sigset as *mut libc::sigset_t, signal as libc::c_int) };
507 /// Remove the specified signal from this set.
509 pub fn remove(&mut self, signal: Signal) {
510 unsafe { libc::sigdelset(&mut self.sigset as *mut libc::sigset_t, signal as libc::c_int) };
513 /// Return whether this set includes the specified signal.
515 pub fn contains(&self, signal: Signal) -> bool {
516 let res = unsafe { libc::sigismember(&self.sigset as *const libc::sigset_t, signal as libc::c_int) };
537 /// Sets the set of signals as the signal mask for the calling thread.
542 /// Adds the set of signals to the signal mask for the calling thread.
547 /// Removes the set of signals from the signal mask for the calling thread.
552 /// Sets the set of signals as the signal mask, and returns the old mask.
560 /// signal mask becomes pending, and returns the accepted signal.
598 for signal in iter {
599 self.add(signal);
628 Some(signal) if self.sigset.contains(signal) => return Some(signal),
643 /// A signal handler.
647 /// Default signal handling.
649 /// Request that the signal be ignored.
651 /// Use the given signal-catching function, which takes in the signal.
653 /// Use the given signal-catching function, which takes in the signal, information about how
654 /// the signal was generated, and a pointer to the threads `ucontext_t`.
660 /// Action to take on receipt of a signal. Corresponds to `sigaction`.
671 /// the signal-catching function.
704 /// signal-catching function.
720 // * The SigHandler was created by signal or sigaction, which
732 // * The SigHandler was created by signal or sigaction, which
744 /// Changes the action taken by a process on receipt of a specific signal.
746 /// `signal` can be any signal except `SIGKILL` or `SIGSTOP`. On success, it returns the previous
747 /// action for the given signal. If `sigaction` fails, no new signal handler is installed.
752 /// what is safe to do in the body of the signal-catching function. Be certain
753 /// to only make syscalls that are explicitly marked safe for signal handlers
756 /// * There is also no guarantee that the old signal handler was installed
761 pub unsafe fn sigaction(signal: Signal, sigaction: &SigAction) -> Result<SigAction> {
764 let res = libc::sigaction(signal as libc::c_int,
771 /// Signal management (see [signal(3p)](https://pubs.opengroup.org/onlinepubs/9699919799/functions/signal.html))
773 /// Installs `handler` for the given `signal`, returning the previous signal
774 /// handler. `signal` should only be used following another call to `signal` or
775 /// if the current handler is the default. The return value of `signal` is
780 /// If the pointer to the previous signal handler is invalid, undefined
788 /// # use nix::sys::signal::{self, Signal, SigHandler};
789 /// unsafe { signal::signal(Signal::SIGINT, SigHandler::SigIgn) }.unwrap();
792 /// Use a signal handler to set a flag variable:
798 /// # use nix::sys::signal::{self, Signal, SigHandler};
803 /// extern fn handle_sigint(signal: libc::c_int) {
804 /// let signal = Signal::try_from(signal).unwrap();
805 /// SIGNALED.store(signal == Signal::SIGINT, Ordering::Relaxed);
810 /// unsafe { signal::signal(Signal::SIGINT, handler) }.unwrap();
819 /// `signal` also returns any error from `libc::signal`, such as when an attempt
820 /// is made to catch a signal that cannot be caught or to ignore a signal that
826 pub unsafe fn signal(signal: Signal, handler: SigHandler) -> Result<SigHandler> {
827 let signal = signal as libc::c_int;
829 SigHandler::SigDfl => libc::signal(signal, libc::SIG_DFL),
830 SigHandler::SigIgn => libc::signal(signal, libc::SIG_IGN),
831 SigHandler::Handler(handler) => libc::signal(signal, handler as libc::sighandler_t),
866 /// Manages the signal mask (set of blocked signals) for the calling thread.
868 /// If the `set` parameter is `Some(..)`, then the signal mask will be updated with the signal set.
872 /// If the 'oldset' parameter is `Some(..)` then the current signal mask will be written into it.
874 /// If both `set` and `oldset` is `Some(..)`, the current signal mask will be written into oldset,
909 /// Send a signal to a process
913 /// * `pid` - Specifies which processes should receive the signal.
915 /// - If zero, the signal will be sent to all processes whose group
919 /// - If `-1` and the process has super-user privileges, the signal
921 /// - If less than `-1`, the signal is sent to all processes whose
923 /// * `signal` - Signal to send. If `None`, error checking is performed
924 /// but no signal is actually sent.
928 pub fn kill<T: Into<Option<Signal>>>(pid: Pid, signal: T) -> Result<()> {
930 match signal.into() {
938 /// Send a signal to a process group
942 /// * `pgrp` - Process group to signal. If less then or equal 1, the behavior
944 /// * `signal` - Signal to send. If `None`, `killpg` will only preform error
945 /// checking and won't send any signal.
949 pub fn killpg<T: Into<Option<Signal>>>(pgrp: Pid, signal: T) -> Result<()> {
951 match signal.into() {
959 /// Send a signal to the current thread
962 pub fn raise(signal: Signal) -> Result<()> {
963 let res = unsafe { libc::raise(signal as libc::c_int) };
970 #![any(feature = "aio", feature = "signal")]
988 /// Notify by delivering a signal to the process.
991 signal: Signal,
993 /// structure of the queued signal.
1007 /// Notify by delivering a signal to a thread.
1012 signal: Signal,
1016 /// structure of the queued signal.
1026 #![any(feature = "aio", feature = "signal")]
1076 SigevNotify::SigevSignal{ signal, .. } => signal as libc::c_int,
1080 SigevNotify::SigevThreadId{ signal, .. } => signal as libc::c_int,
1149 for signal in Signal::iterator() {
1150 assert!(!set.contains(signal));
1156 for signal in Signal::iterator() {
1157 assert_eq!(signal.as_ref().parse::<Signal>().unwrap(), signal);
1158 assert_eq!(signal.to_string().parse::<Signal>().unwrap(), signal);
1188 .expect("Failed to get existing signal mask!");
1202 .expect("Failed to revert signal mask!");
1337 for signal in Signal::iterator() {
1338 assert!(!set.contains(signal));
1344 for signal in Signal::iterator() {
1345 assert!(set.contains(signal));