I have a real-time application that needs to be able to recover from a segfault in a timely manner. To accomplish this, I'd like to do a fork within a segv signal handler. The parent would release several locks, do some basic cleanup, and exit immediately. (A new instance of the process would start immediately after the previous one exited). The child fork would lower its priority, dump some diagnostic information in the background, and exit as well.
My problem is that if the process has called pthread_atfork(...), and has registered non-async safe callbacks, then fork() is no longer async safe, and I can't fork from within the signal handler. I'm wondering if there's any existing mechanism to detect whether or not a process has registered an atfork callback, or even better, if it's possible to disable all pthread_atfork() callbacks before forking. My current understanding is that pthread_atfork(a,b,c) will not override the previous callbacks, but rather add to them, thus calling this with NULL's would not reset them.