I've read that a lot can happen when mixing threads and forking and it should better be avoided. I'm finding myself in a situation where I don't have a choice and I receive a kernel-crash of my kernel-module.
My reduced test-case has 2 threads. One of it is doing ioctls to an open device-node in a loop. The other one is doing one fork, waits for the child to exit, which it does immediately. If I use pthread_atfork
to synchronized my thread with the fork-call it is working.
Where can I look at to find out more on what happens during a fork on open file-descriptors which are currently executing an ioctl
? What kind of corruption can happen?
EDIT: Andreas made me change my test case. Instead of having the child exiting immediatly I'm not waiting 10 seconds before exiting. I'm collecting all PID in the parent-process to later do a waitpid. I'm forking 100 times. If makes it crash after 2 or 3 forks.