Signal management in Sys (Sys.set_signal)

That’s a tough question! OCaml just makes available the whole list of POSIX signals… even though some of them like SIGSEGV or SIGFPE are generally raised synchronously, in a way that OCaml cannot handle. Better documentation is in order.

Back to your bigger question: it’s exceedingly hard to safely recover from a segv, even from C ! Even if you handle the segv signal from C, you won’t know in which state the program is, so running any nontrivial code (e.g. printf()) at this point is unsafe, let alone trying to callback into Caml.

If you can’t write a core dump, could you at least run the program under a debugger? or monitor it with ptrace() from another process?

1 Like