• Home
  • Raw
  • Download

Lines Matching full:signal

24 #[cfg(any(feature = "aio", feature = "signal"))]
27 #[cfg(any(feature = "aio", feature = "process", feature = "signal"))]
31 // type for signal constants.
36 #[cfg_attr(docsrs, doc(cfg(any(feature = "aio", feature = "signal"))))]
37 pub enum Signal {
56 /// User defined signal 1
60 /// User defined signal 2
66 /// Software termination signal from kill
81 /// Sendable stop signal not from tty
83 /// Stop signal from tty
101 /// Input/output possible signal
124 #[cfg(feature = "signal")]
125 impl FromStr for Signal { implementation
127 fn from_str(s: &str) -> Result<Signal> { in from_str() argument
129 "SIGHUP" => Signal::SIGHUP, in from_str()
130 "SIGINT" => Signal::SIGINT, in from_str()
131 "SIGQUIT" => Signal::SIGQUIT, in from_str()
132 "SIGILL" => Signal::SIGILL, in from_str()
133 "SIGTRAP" => Signal::SIGTRAP, in from_str()
134 "SIGABRT" => Signal::SIGABRT, in from_str()
135 "SIGBUS" => Signal::SIGBUS, in from_str()
136 "SIGFPE" => Signal::SIGFPE, in from_str()
137 "SIGKILL" => Signal::SIGKILL, in from_str()
138 "SIGUSR1" => Signal::SIGUSR1, in from_str()
139 "SIGSEGV" => Signal::SIGSEGV, in from_str()
140 "SIGUSR2" => Signal::SIGUSR2, in from_str()
141 "SIGPIPE" => Signal::SIGPIPE, in from_str()
142 "SIGALRM" => Signal::SIGALRM, in from_str()
143 "SIGTERM" => Signal::SIGTERM, in from_str()
158 "SIGSTKFLT" => Signal::SIGSTKFLT, in from_str()
159 "SIGCHLD" => Signal::SIGCHLD, in from_str()
160 "SIGCONT" => Signal::SIGCONT, in from_str()
161 "SIGSTOP" => Signal::SIGSTOP, in from_str()
162 "SIGTSTP" => Signal::SIGTSTP, in from_str()
163 "SIGTTIN" => Signal::SIGTTIN, in from_str()
164 "SIGTTOU" => Signal::SIGTTOU, in from_str()
165 "SIGURG" => Signal::SIGURG, in from_str()
166 "SIGXCPU" => Signal::SIGXCPU, in from_str()
167 "SIGXFSZ" => Signal::SIGXFSZ, in from_str()
168 "SIGVTALRM" => Signal::SIGVTALRM, in from_str()
169 "SIGPROF" => Signal::SIGPROF, in from_str()
170 "SIGWINCH" => Signal::SIGWINCH, in from_str()
172 "SIGIO" => Signal::SIGIO, in from_str()
178 "SIGPWR" => Signal::SIGPWR, in from_str()
179 "SIGSYS" => Signal::SIGSYS, in from_str()
187 "SIGEMT" => Signal::SIGEMT, in from_str()
196 "SIGINFO" => Signal::SIGINFO, in from_str()
202 #[cfg(feature = "signal")]
203 impl Signal { implementation
204 /// Returns name of signal.
206 /// This function is equivalent to `<Signal as AsRef<str>>::as_ref()`,
211 Signal::SIGHUP => "SIGHUP", in as_str()
212 Signal::SIGINT => "SIGINT", in as_str()
213 Signal::SIGQUIT => "SIGQUIT", in as_str()
214 Signal::SIGILL => "SIGILL", in as_str()
215 Signal::SIGTRAP => "SIGTRAP", in as_str()
216 Signal::SIGABRT => "SIGABRT", in as_str()
217 Signal::SIGBUS => "SIGBUS", in as_str()
218 Signal::SIGFPE => "SIGFPE", in as_str()
219 Signal::SIGKILL => "SIGKILL", in as_str()
220 Signal::SIGUSR1 => "SIGUSR1", in as_str()
221 Signal::SIGSEGV => "SIGSEGV", in as_str()
222 Signal::SIGUSR2 => "SIGUSR2", in as_str()
223 Signal::SIGPIPE => "SIGPIPE", in as_str()
224 Signal::SIGALRM => "SIGALRM", in as_str()
225 Signal::SIGTERM => "SIGTERM", in as_str()
240 Signal::SIGSTKFLT => "SIGSTKFLT", in as_str()
241 Signal::SIGCHLD => "SIGCHLD", in as_str()
242 Signal::SIGCONT => "SIGCONT", in as_str()
243 Signal::SIGSTOP => "SIGSTOP", in as_str()
244 Signal::SIGTSTP => "SIGTSTP", in as_str()
245 Signal::SIGTTIN => "SIGTTIN", in as_str()
246 Signal::SIGTTOU => "SIGTTOU", in as_str()
247 Signal::SIGURG => "SIGURG", in as_str()
248 Signal::SIGXCPU => "SIGXCPU", in as_str()
249 Signal::SIGXFSZ => "SIGXFSZ", in as_str()
250 Signal::SIGVTALRM => "SIGVTALRM", in as_str()
251 Signal::SIGPROF => "SIGPROF", in as_str()
252 Signal::SIGWINCH => "SIGWINCH", in as_str()
254 Signal::SIGIO => "SIGIO", in as_str()
261 Signal::SIGPWR => "SIGPWR", in as_str()
262 Signal::SIGSYS => "SIGSYS", in as_str()
270 Signal::SIGEMT => "SIGEMT", in as_str()
279 Signal::SIGINFO => "SIGINFO", in as_str()
284 #[cfg(feature = "signal")]
285 impl AsRef<str> for Signal { implementation
291 #[cfg(feature = "signal")]
292 impl fmt::Display for Signal { implementation
298 #[cfg(feature = "signal")]
299 pub use self::Signal::*;
302 #[cfg(feature = "signal")]
303 const SIGNALS: [Signal; 29] = [
310 #[cfg(feature = "signal")]
311 const SIGNALS: [Signal; 28] = [
327 #[cfg(feature = "signal")]
328 const SIGNALS: [Signal; 31] = [
344 #[cfg(feature = "signal")]
345 const SIGNALS: [Signal; 30] = [
352 #[cfg(feature = "signal")]
353 const SIGNALS: [Signal; 30] = [
367 #[cfg(feature = "signal")]
368 const SIGNALS: [Signal; 31] = [
376 #![feature = "signal"]
385 type Item = Signal;
387 fn next(&mut self) -> Option<Signal> {
398 impl Signal { impl
406 pub const SIGIOT : Signal = SIGABRT;
409 pub const SIGPOLL : Signal = SIGIO;
411 pub const SIGUNUSED : Signal = SIGSYS;
424 #[cfg(feature = "signal")]
427 #[cfg_attr(docsrs, doc(cfg(feature = "signal")))]
429 /// When catching a [`Signal::SIGCHLD`] signal, the signal will be
433 /// When catching a [`Signal::SIGCHLD`] signal, the system will not
437 /// Further occurrences of the delivered signal are not masked during
440 /// The system will deliver the signal to the process on a signal stack,
443 /// The handler is reset back to the default at the moment the signal is
447 /// signal. See the man page for complete details.
454 #[cfg(feature = "signal")]
456 /// Specifies how certain functions should manipulate a signal mask
459 #[cfg_attr(docsrs, doc(cfg(feature = "signal")))]
472 #![feature = "signal"]
479 /// Specifies a set of [`Signal`]s that may be blocked, waited for, etc.
507 /// Add the specified signal to the set.
509 pub fn add(&mut self, signal: Signal) {
510 unsafe { libc::sigaddset(&mut self.sigset as *mut libc::sigset_t, signal as libc::c_int) };
519 /// Remove the specified signal from this set.
521 pub fn remove(&mut self, signal: Signal) {
522 unsafe { libc::sigdelset(&mut self.sigset as *mut libc::sigset_t, signal as libc::c_int) };
525 /// Return whether this set includes the specified signal.
527 pub fn contains(&self, signal: Signal) -> bool {
528 …let res = unsafe { libc::sigismember(&self.sigset as *const libc::sigset_t, signal as libc::c_int)…
549 /// Sets the set of signals as the signal mask for the calling thread.
554 /// Adds the set of signals to the signal mask for the calling thread.
559 /// Removes the set of signals from the signal mask for the calling thread.
564 /// Sets the set of signals as the signal mask, and returns the old mask.
572 /// signal mask becomes pending, and returns the accepted signal.
574 pub fn wait(&self) -> Result<Signal> {
581 Signal::try_from(signum.assume_init()).unwrap()
585 /// Wait for a signal
628 impl From<Signal> for SigSet {
629 fn from(signal: Signal) -> SigSet {
631 sigset.add(signal);
636 impl BitOr for Signal {
647 impl BitOr<Signal> for SigSet {
650 fn bitor(mut self, rhs: Signal) -> Self::Output {
671 impl Extend<Signal> for SigSet {
673 where T: IntoIterator<Item = Signal> {
674 for signal in iter {
675 self.add(signal);
680 impl FromIterator<Signal> for SigSet {
682 where T: IntoIterator<Item = Signal> {
691 for signal in Signal::iterator() {
692 if self.contains(signal) != other.contains(signal) {
702 for signal in Signal::iterator() {
703 if self.contains(signal) {
704 signal.hash(state);
720 type Item = Signal;
721 fn next(&mut self) -> Option<Signal> {
725 Some(signal) if self.sigset.contains(signal) => return Some(signal),
733 type Item = Signal;
736 SigSetIter { sigset: self, inner: Signal::iterator() }
740 /// A signal handler.
743 /// Default signal handling.
745 /// Request that the signal be ignored.
747 /// Use the given signal-catching function, which takes in the signal.
749 /// Use the given signal-catching function, which takes in the signal, information about how
750 /// the signal was generated, and a pointer to the threads `ucontext_t`.
755 /// Action to take on receipt of a signal. Corresponds to `sigaction`.
773 /// the signal-catching function.
821 /// signal-catching function.
838 // * The SigHandler was created by signal or sigaction, which
850 // * The SigHandler was created by signal or sigaction, which
882 /// Changes the action taken by a process on receipt of a specific signal.
884 /// `signal` can be any signal except `SIGKILL` or `SIGSTOP`. On success, it returns the previous
885 /// action for the given signal. If `sigaction` fails, no new signal handler is installed.
889 /// * Signal handlers may be called at any point during execution, which limits
890 /// what is safe to do in the body of the signal-catching function. Be certain
891 /// to only make syscalls that are explicitly marked safe for signal handlers
894 /// * There is also no guarantee that the old signal handler was installed
899 pub unsafe fn sigaction(signal: Signal, sigaction: &SigAction) -> Result<SigAction> {
902 let res = unsafe { libc::sigaction(signal as libc::c_int,
909 /// Signal management (see [signal(3p)](https://pubs.opengroup.org/onlinepubs/9699919799/functions/
911 /// Installs `handler` for the given `signal`, returning the previous signal
912 /// handler. `signal` should only be used following another call to `signal` or
913 /// if the current handler is the default. The return value of `signal` is
918 /// If the pointer to the previous signal handler is invalid, undefined
926 /// # use nix::sys::signal::{self, Signal, SigHandler};
927 /// unsafe { signal::signal(Signal::SIGINT, SigHandler::SigIgn) }.unwrap();
930 /// Use a signal handler to set a flag variable:
935 /// # use nix::sys::signal::{self, Signal, SigHandler};
938 /// extern fn handle_sigint(signal: libc::c_int) {
939 /// let signal = Signal::try_from(signal).unwrap();
940 /// SIGNALED.store(signal == Signal::SIGINT, Ordering::Relaxed);
945 /// unsafe { signal::signal(Signal::SIGINT, handler) }.unwrap();
954 /// `signal` also returns any error from `libc::signal`, such as when an attempt
955 /// is made to catch a signal that cannot be caught or to ignore a signal that
961 pub unsafe fn signal(signal: Signal, handler: SigHandler) -> Result<SigHandler> {
962 let signal = signal as libc::c_int; localVariable
964 SigHandler::SigDfl => unsafe { libc::signal(signal, libc::SIG_DFL) },
965 SigHandler::SigIgn => unsafe { libc::signal(signal, libc::SIG_IGN) },
966 … SigHandler::Handler(handler) => unsafe { libc::signal(signal, handler as libc::sighandler_t) },
999 /// Manages the signal mask (set of blocked signals) for the calling thread.
1001 /// If the `set` parameter is `Some(..)`, then the signal mask will be updated with the signal set.
1005 /// If the 'oldset' parameter is `Some(..)` then the current signal mask will be written into it.
1007 /// If both `set` and `oldset` is `Some(..)`, the current signal mask will be written into oldset,
1042 /// Send a signal to a process
1046 /// * `pid` - Specifies which processes should receive the signal.
1048 /// - If zero, the signal will be sent to all processes whose group
1052 /// - If `-1` and the process has super-user privileges, the signal
1054 /// - If less than `-1`, the signal is sent to all processes whose
1056 /// * `signal` - Signal to send. If `None`, error checking is performed
1057 /// but no signal is actually sent.
1061 pub fn kill<T: Into<Option<Signal>>>(pid: Pid, signal: T) -> Result<()> {
1063 match signal.into() {
1071 /// Send a signal to a process group
1075 /// * `pgrp` - Process group to signal. If less then or equal 1, the behavior
1077 /// * `signal` - Signal to send. If `None`, `killpg` will only preform error
1078 /// checking and won't send any signal.
1082 pub fn killpg<T: Into<Option<Signal>>>(pgrp: Pid, signal: T) -> Result<()> {
1084 match signal.into() {
1092 /// Send a signal to the current thread
1095 pub fn raise(signal: Signal) -> Result<()> {
1096 let res = unsafe { libc::raise(signal as libc::c_int) };
1103 #![any(feature = "aio", feature = "signal")]
1121 /// Notify by delivering a signal to the process.
1123 /// Signal to deliver
1124 signal: Signal,
1126 /// structure of the queued signal.
1149 /// Notify by delivering a signal to a thread.
1156 /// Signal to send
1157 signal: Signal,
1161 /// structure of the queued signal.
1175 #![any(feature = "aio", feature = "signal")]
1333 SigevNotify::SigevSignal{signal, si_value} => {
1335 sev.sigev_signo = signal as libc::c_int;
1353 SigevNotify::SigevThreadId{signal, thread_id, si_value} => {
1355 sev.sigev_signo = signal as libc::c_int;
1360 SigevNotify::SigevThreadId{signal, thread_id, si_value} => {
1362 sev.sigev_signo = signal as libc::c_int;