public static SigAction RegisterExceptionHandler(IntPtr action)
        {
            SigAction sig = new SigAction
            {
                sa_handler = action,
                sa_flags   = SA_SIGINFO
            };

            sigemptyset(ref sig.sa_mask);

            int result = sigaction(SIGSEGV, ref sig, out SigAction old);

            if (result != 0)
            {
                throw new InvalidOperationException($"Could not register SIGSEGV sigaction. Error: {result}");
            }

            if (OperatingSystem.IsMacOS())
            {
                result = sigaction(SIGBUS, ref sig, out SigAction oldb);

                if (result != 0)
                {
                    throw new InvalidOperationException($"Could not register SIGBUS sigaction. Error: {result}");
                }
            }

            return(old);
        }
Example #2
0
        public static SigAction RegisterExceptionHandler(IntPtr action)
        {
            SigAction sig = new SigAction
            {
                sa_handler = action,
                sa_flags   = SA_SIGINFO
            };

            sigemptyset(ref sig.sa_mask);

            sigaction((int)Signum.SIGSEGV, ref sig, out SigAction old);

            return(old);
        }
Example #3
0
        public static SigAction RegisterExceptionHandler(IntPtr action)
        {
            SigAction sig = new SigAction
            {
                sa_handler = action,
                sa_flags   = SA_SIGINFO
            };

            sigemptyset(ref sig.sa_mask);

            int result = sigaction((int)Signum.SIGSEGV, ref sig, out SigAction old);

            if (result != 0)
            {
                throw new InvalidOperationException($"Could not register sigaction. Error: {result}");
            }

            return(old);
        }
 public static bool RestoreExceptionHandler(SigAction oldAction)
 {
     return(sigaction(SIGSEGV, ref oldAction, out SigAction _) == 0 && (!OperatingSystem.IsMacOS() || sigaction(SIGBUS, ref oldAction, out SigAction _) == 0));
 }
 private static extern int sigaction(int signum, ref SigAction sigAction, out SigAction oldAction);
Example #6
0
 public static bool RestoreExceptionHandler(SigAction oldAction)
 {
     return(sigaction((int)Signum.SIGSEGV, ref oldAction, out SigAction _) == 0);
 }