I have a library which registers an atfork handler (via pthread_atfork()) which does not support multiple threads when fork() is calle
Yes. The following should work on Linux (and, I think, all glibc based platforms):
#define _GNU_SOURCE
#include
#include
...
syscall(SYS_fork);
This bypasses the library and directly calls the system call for fork. You might run into trouble if your platform does not implement fork as a single system call. For Linux, that simply means that you should use clone instead.
With that in mind, I'm not sure I'd recomment doing that. Since you're a library, you have no idea why someone registered an atfork. Assuming it's irrelevant is bad programming practice.
So you lose portability in order to do something that may or may not break stuff, all in the name of, what? Saving a few function calls? Personally, I'd just use fork.