Standby: World-Class Cross-Platform Time Management Tool
A comprehensive, production-ready Rust CLI tool for time management across all platforms. Standby provides a unified interface for sleep, timeout, wait, and delay operations with full POSIX compliance and GNU coreutils compatibility.
Features
-
Universal Time Format Parser: Flexible parsing of time durations
- Integer seconds:
5 - Floating-point seconds:
5.5 - Unit suffixes:
1s,1m,1h,1d - Compound formats:
1h30m45s - Special values:
infinity
- Integer seconds:
-
Cross-Platform Support: Works seamlessly on Unix/Linux, macOS, and Windows
- Native signal handling for Unix/Linux
- Windows console handler support
- Platform-specific optimizations
-
Three Core Commands:
- sleep - Suspend execution for a specified duration
- timeout - Run commands with time limits and signal escalation
- wait - Wait for processes to complete with optional timeout
Building
The binary will be at target/release/standby.
Usage
Sleep Command
# Basic usage (5 seconds)
# Various time formats
Timeout Command
# Run a command with a 10-second timeout
# Using signal options
# Signal escalation: send SIGTERM, then SIGKILL after 2 seconds
# Preserve exit status of the command
Wait Command
# Wait for a process to complete
# Wait for multiple processes
# Wait with timeout
Testing
Run all tests (unit + integration):
Run only unit tests:
Run only integration tests:
Project Structure
src/
├── main.rs # CLI entry point
├── lib.rs # Library exports
├── errors.rs # Error types
├── commands/
│ ├── mod.rs # Command CLI setup
│ ├── sleep.rs # Sleep subcommand
│ ├── timeout.rs # Timeout subcommand
│ └── wait.rs # Wait subcommand
├── time/
│ ├── mod.rs # Time module exports
│ ├── parser.rs # Duration format parser
│ └── duration.rs # Duration type
└── signals/
├── mod.rs # Signal handler abstraction
├── unix.rs # Unix/Linux signal handling
└── windows.rs # Windows signal handling
tests/
└── integration_tests.rs # End-to-end tests
POSIX Compliance
Standby is designed with POSIX compliance as the baseline, with extensions for GNU coreutils compatibility:
- ✅ POSIX sleep with integer seconds
- ✅ GNU extensions: floating-point, unit suffixes
- ✅ Signal handling per POSIX specification
- ✅ Process timeout implementation
- ✅ Cross-platform compatibility
Test Coverage
-
20 unit tests covering:
- Time format parsing (integer, float, suffixes, compound)
- Duration calculations
- Special values (infinity)
-
14 integration tests covering:
- Sleep with various time formats
- Timeout with process termination
- Signal handling
- CLI help and version
- Error handling
Exit Codes
0: Successful completion1: Timeout occurred or command failed- Other codes: Exit code from the executed command
Dependencies
- clap - CLI argument parsing with derive macros
- anyhow/thiserror - Error handling
- tokio - Async runtime
- ctrlc - Signal handling
- nix - Unix syscall bindings (Unix only)
- winapi - Windows API bindings (Windows only)
Performance
Standby is compiled to native binaries with optimizations enabled, providing near-native performance with minimal overhead.
Future Enhancements
- Support for additional signals (SIGSTOP, SIGCONT, etc.)
- Microsecond/nanosecond precision for specialized use cases
- Integration with cron/at for scheduling
- Process group management
- Resource limits (CPU time, memory)
License
MIT or Apache 2.0 (standard Rust project licenses)