@@ -1633,7 +1633,8 @@ pub mod alarm {
1633
1633
//!
1634
1634
//! Scheduling an alarm and waiting for the signal:
1635
1635
//!
1636
- //! ```
1636
+ #![ cfg_attr( target_os = "redox" , doc = " ```rust,ignore" ) ]
1637
+ #![ cfg_attr( not( target_os = "redox" ) , doc = " ```rust" ) ]
1637
1638
//! use std::time::{Duration, Instant};
1638
1639
//!
1639
1640
//! use nix::unistd::{alarm, pause};
@@ -1642,14 +1643,23 @@ pub mod alarm {
1642
1643
//! // We need to setup an empty signal handler to catch the alarm signal,
1643
1644
//! // otherwise the program will be terminated once the signal is delivered.
1644
1645
//! extern fn signal_handler(_: nix::libc::c_int) { }
1645
- //! unsafe { sigaction(Signal::SIGALRM, &SigAction::new(SigHandler::Handler(signal_handler), SaFlags::empty(), SigSet::empty())); }
1646
+ //! let sa = SigAction::new(
1647
+ //! SigHandler::Handler(signal_handler),
1648
+ //! SaFlags::empty(),
1649
+ //! SigSet::empty()
1650
+ //! );
1651
+ //! unsafe {
1652
+ //! sigaction(Signal::SIGALRM, &sa);
1653
+ //! }
1646
1654
//!
1647
1655
//! // Set an alarm for 1 second from now.
1648
1656
//! alarm::set(1);
1649
1657
//!
1650
1658
//! let start = Instant::now();
1651
1659
//! // Pause the process until the alarm signal is received.
1652
- //! pause();
1660
+ //! let mut sigset = SigSet::empty();
1661
+ //! sigset.add(Signal::SIGALRM);
1662
+ //! sigset.wait();
1653
1663
//!
1654
1664
//! assert!(start.elapsed() >= Duration::from_secs(1));
1655
1665
//! ```
0 commit comments