Ejemplo n.º 1
0
        internal object trap(object sig, object arg)
        {
            int signal = 0;
            switch (((String)sig).value)
            {
                case "SIGINT":
                    signal = 2; 
                    break;
                case "SIGILL":
                    signal = 4;
                    break;
                case "SIGFPE":
                    signal = 8;
                    break;
                case "SIGSEGV":
                    signal = 11;
                    break;
                case "SIGTERM":
                    signal = 15;
                    break;
                case "SIGBREAK":
                    signal = 21;
                    break;
                case "SIGABRT":
                    signal = 22;
                    break;
            }

            sighandler handler;
            if (arg is Proc)
                handler = new sighandler(new Handler((Proc)arg).HandleSignal);
            else if (arg is sighandler)
                handler = (sighandler)arg;
            else
                handler = null;

            handlers.Add(handler); // (avoid garbage collection of unmanaged handlers)

            return Stdlib.signal(signal, handler).ToInt32();
        }
Ejemplo n.º 2
0
 internal static extern System.IntPtr signal(int signum, sighandler handler);