# Idea #1 (Probably not) Place some sort of guard around fork in the posix module that checks for any active threads before forking.
There are async-signal-safe routines that can are valid to call post-fork. Maybe not a good idea to change the expected behavior of the OS-specific fork behavior. * * * # Idea #2 (Easiest) Install a pthread_atfork handler. The parent handler could either clear the appropriate locks and terminate the running threads or quit and warn against the dangerous behavior. Further investigation could be made to see if similar measures are required for other operating systems. * * * # Idea #3 (Most flexible?) Add a check in threadpool.nim for a flag like \--define:threadpoolExplicitSetup. I like the default behavior of threadpool as it is currently. There is code in the main body of threadpool.nim that initializes locks and spawns threads. When the above flag is defined, explicit procs could be exposed that allows the user to explicitly control when the thread spawning behavior occurs.