Mono Class Library: Mono.Posix.Syscall Overview | MembersMono.Posix.Syscall.signal Method |
Register a handler for a given posix signal. [Edit]
|
- signum
- a int. The signal() function returns the previous value of the signal handler, or SIG_ERR on error and System.Runtime.InteropServices.Marshal.GetLastWin32Error is set. [Edit]
- handler
- a Mono.Posix.Syscall.sighandler_t [Edit]
a int [Edit]
This member is obsolete. Please use Mono.Unix.Native.Stdlib.signal instead.
See 'man signal(2)' and 'man signal(7)' for more information and error codes.
[Edit]
C# Example /* Possible signal values list: Signal Value Action Comment ----------------------------------------------------------------------- SIGHUP 1 Term Hangup detected on controlling terminal or death of controlling process SIGINT 2 Term Interrupt from keyboard SIGQUIT 3 Core Quit from keyboard SIGILL 4 Core Illegal Instruction SIGABRT 6 Core Abort signal from abort(3) SIGFPE 8 Core Floating point exception SIGKILL 9 Term Kill signal SIGSEGV 11 Core Invalid memory reference SIGPIPE 13 Term Broken pipe: write to pipe with no readers SIGALRM 14 Term Timer signal from alarm(2) SIGTERM 15 Term Termination signal SIGUSR1 30,10,16 Term User-defined signal 1 SIGUSR2 31,12,17 Term User-defined signal 2 SIGCHLD 20,17,18 Ign Child stopped or terminated SIGCONT 19,18,25 Continue if stopped SIGSTOP 17,19,23 Stop Stop process SIGTSTP 18,20,24 Stop Stop typed at tty SIGTTIN 21,21,26 Stop tty input for background process SIGTTOU 22,22,27 Stop tty output for background process */ using System; using Mono.Posix; using System.Runtime.InteropServices; class Test { public void SignalCatcher(int v) { Console.WriteLine("Signal received: " + v); } public static void Main(string[] args) { Test t = new Test(); Console.Write("waiting for event..."); string x = Console.ReadLine(); } public Test() { Console.WriteLine("signal result: " + Syscall.signal(14, new Syscall.sighandler_t(SignalCatcher))); Syscall.alarm(3); } }
Namespace: Mono.Posix
Assembly: Mono.Posix (in Mono.Posix.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0