DaemonManager
is a comprehensive command-line tool for managing daemon processes and system signals. This enhanced version combines an intuitive Bash interface with a robust C program for advanced signal handling, providing developers and system administrators with powerful process management capabilities.
The Daemon Manager running in terminal, showing the main menu and process management capabilities
- Process Management: Create, monitor, and control daemon processes
- Signal Handling: Advanced signal management with custom handlers
- Real-time Monitoring: Live process tracking and log monitoring
- Process Statistics: Detailed information about running processes
- Configuration Management: Customizable settings and preferences
- Data Export: Export process data in JSON format
- Backup & Recovery: Automatic backup of existing installations
- Multiple Process Types: Counter processes, custom commands, file monitoring
- Advanced Query Options: System processes, process trees, resource usage
- Graceful Shutdown: Clean termination with optional process cleanup
- State Persistence: Save and restore process states across sessions
- Error Handling: Comprehensive error checking and validation
- Colored Output: Beautiful, readable terminal interface
- Process Limits: Configurable maximum process limits
- Log Management: Organized logging with rotation support
- Operating System: Linux or macOS with Bash support
- Compiler: GCC (GNU Compiler Collection)
- Shell: Bash 4.0 or later
- Privileges: Root/sudo access for system-wide installation
- Dependencies: Standard POSIX utilities (ps, kill, tail, etc.)
# Clone the repository
git clone https://github.com/hamdiitarek/daemon-manager.git
cd daemon-manager
# Run the installation script
sudo ./install.sh
# Build and install using make
make all
sudo make install
# Compile the C program
gcc -Wall -Wextra -std=c99 -O2 -o signal_handler signal_handler.c
# Copy files to system directory
sudo cp DaemonManager /usr/local/bin/
sudo cp signal_handler /usr/local/bin/
sudo chmod +x /usr/local/bin/DaemonManager
sudo chmod +x /usr/local/bin/signal_handler
The installation script supports several options:
sudo ./install.sh --help # Show help
sudo ./install.sh --force # Force installation
sudo ./install.sh --backup # Create backup only
sudo ./install.sh --uninstall # Uninstall Daemon Manager
DaemonManager
-
Create Process: Create new daemon processes
- Simple counter processes
- Custom command execution
- File/directory monitoring
-
Query Processes: View process information
- All system processes
- Managed processes only
- Specific process details
- Process tree visualization
- System resource usage
-
Track Process: Monitor process logs in real-time
-
Send Signals: Advanced signal handling interface
-
Kill Process: Terminate processes gracefully or forcefully
-
Cleanup Dead Processes: Remove terminated processes from management
-
Show Statistics: Display system and tool statistics
-
Export Process Data: Export process information to JSON
-
Configuration: Manage tool settings
-
Exit: Clean shutdown with optional process cleanup
The signal handler program provides:
- Custom Signal Handlers: Override default signal behavior
- Signal Information: Detailed signal descriptions
- Interactive Testing: Send various signals for testing
- Status Tracking: Monitor handler state
- Educational Mode: Learn about different signal types
Edit daemon_manager.conf
or use the configuration menu:
# Maximum processes
MAX_PROCESSES=50
# Log directory
LOG_DIRECTORY="./logs"
# Auto cleanup
AUTO_CLEANUP=true
# Verbose logging
VERBOSE_LOGGING=false
DaemonManager/
├── DaemonManager # Main Bash script
├── signal_handler.c # C signal handling program
├── install.sh # Enhanced installation script
├── uninstall.sh # Uninstallation script
├── Makefile # Build automation
├── daemon_manager.conf # Configuration file
├── README.md # This documentation
└── logs/ # Log directory
├── daemon_manager.log # Main application log
├── daemon_state.txt # Process state file
└── process_*.log # Individual process logs
# Example: Create a custom monitoring process
DaemonManager
> 1 (Create Process)
> 2 (Custom command process)
> Command: "watch -n 1 'df -h'"
> Name: disk_monitor
# View comprehensive system information
DaemonManager
> 2 (Query Processes)
> 5 (System resource usage)
# Export current process data to JSON
DaemonManager
> 8 (Export Process Data)
# Creates: logs/daemon_export_YYYYMMDD_HHMMSS.json
# Test signal handling
DaemonManager
> 4 (Send Signals)
> 1 (Override signal handlers)
> 9 (Send SIGINT Signal)
# Clone repository
git clone https://github.com/hamditarek/daemon-manager.git
cd daemon-manager
# Build signal handler
make all
# Run tests
make test
# Build with debug information
make debug
- DaemonManager: Main Bash script with modular functions
- signal_handler.c: C program for signal management
- install.sh: Installation automation with error handling
- Makefile: Build system for easy compilation
Enable verbose logging in configuration:
VERBOSE_LOGGING=true
# View main application log
tail -f logs/daemon_manager.log
# View specific process log
tail -f logs/process_1.log
# View all logs
find logs/ -name "*.log" -exec tail -f {} +
- Installation requires root privileges
- Running requires user-level permissions
- Process isolation through
setsid
- Safe signal handling
- Regular cleanup of old log files
- Monitor process resource usage
- Use process limits to prevent resource exhaustion
- Validate custom commands before execution
Note: This tool is designed for educational and development purposes. Use responsibly and ensure you understand the implications of signal handling and process management in production environments.