|
// retoor <retoor@molodetz.nl>
|
|
|
|
import "signal" for Signal
|
|
|
|
System.print("=== Signal Module Demo ===\n")
|
|
|
|
System.print("--- Available Signal Constants ---")
|
|
System.print("SIGHUP: %(Signal.SIGHUP)")
|
|
System.print("SIGINT: %(Signal.SIGINT)")
|
|
System.print("SIGQUIT: %(Signal.SIGQUIT)")
|
|
System.print("SIGTERM: %(Signal.SIGTERM)")
|
|
System.print("SIGUSR1: %(Signal.SIGUSR1)")
|
|
System.print("SIGUSR2: %(Signal.SIGUSR2)")
|
|
|
|
System.print("\n--- Signal API Overview ---")
|
|
System.print("The Signal module provides:")
|
|
System.print(" Signal.trap(signum, fn) - Set a handler for a signal")
|
|
System.print(" Signal.ignore(signum) - Ignore a signal")
|
|
System.print(" Signal.reset(signum) - Reset to default behavior")
|
|
|
|
System.print("\n--- Example Usage ---")
|
|
System.print("To handle SIGINT (Ctrl+C):")
|
|
System.print(" Signal.trap(Signal.SIGINT) {")
|
|
System.print(" System.print(\"Interrupted!\")")
|
|
System.print(" }")
|
|
|
|
System.print("\nTo ignore SIGTERM:")
|
|
System.print(" Signal.ignore(Signal.SIGTERM)")
|
|
|
|
System.print("\nTo reset SIGHUP to default:")
|
|
System.print(" Signal.reset(Signal.SIGHUP)")
|
|
|
|
System.print("\n--- Notes ---")
|
|
System.print("Signal handling is useful for:")
|
|
System.print(" - Graceful shutdown on SIGTERM/SIGINT")
|
|
System.print(" - Reloading configuration on SIGHUP")
|
|
System.print(" - Custom actions on SIGUSR1/SIGUSR2")
|
|
|
|
System.print("\n--- Demo Complete ---")
|