Lines Matching defs:alarm
1753 pub mod alarm {
1756 //! Scheduling an alarm will trigger a `SIGALRM` signal when the time has
1764 //! Canceling an alarm:
1767 //! use nix::unistd::alarm;
1769 //! // Set an alarm for 60 seconds from now.
1770 //! alarm::set(60);
1772 //! // Cancel the above set alarm, which returns the number of seconds left
1773 //! // of the previously set alarm.
1774 //! assert_eq!(alarm::cancel(), Some(60));
1777 //! Scheduling an alarm and waiting for the signal:
1783 //! use nix::unistd::{alarm, pause};
1786 //! // We need to setup an empty signal handler to catch the alarm signal,
1800 //! // Set an alarm for 1 second from now.
1801 //! alarm::set(1);
1803 //! // Pause the process until the alarm signal is received.
1813 //! See also [alarm(2)](https://pubs.opengroup.org/onlinepubs/9699919799/functions/alarm.html).
1815 /// Schedule an alarm signal.
1820 /// Returns the leftover time of a previously set alarm if there was one.
1822 assert!(secs != 0, "passing 0 to `alarm::set` is not allowed, to cancel an alarm use `alarm::cancel`");
1823 alarm(secs)
1826 /// Cancel an previously set alarm signal.
1828 /// Returns the leftover time of a previously set alarm if there was one.
1830 alarm(0)
1833 fn alarm(secs: libc::c_uint) -> Option<libc::c_uint> {
1834 match unsafe { libc::alarm(secs) } {