title: What happens during an ioctl/syscall done in thread while another thread is forking?
body: <p>I've read that <a href="http://maxim.int.ru/bookshelf/PthreadsProgram/htm/r_44.html" rel="nofollow">a lot</a> 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.</p>
  
  <p>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 <code>pthread_atfork</code> to synchronized my thread with the fork-call it is working.</p>
  
  <p>Where can I look at to find out more on what happens during a fork on open file-descriptors which are currently executing an <code>ioctl</code>? What kind of corruption can happen?</p>
  
  <p><em>EDIT</em>: 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.</p>