Am 24.08.11 04:50, schrieb Mouse: >>> Well, you need to open it first, before you can to ioctl, and if >>> only one process can open it, only one process can ioctl it, right? >> Wrong. > > Agreed. > >> Multiple threads can ioctl and nobody prevents one from having a >> single process with multiple threads (pthreads, if you like). > > Not only that, but even without threading, there are at least two ways > I can think of offhand that a file descriptor, once opened, can end up > in multiple processes' open file tables: fork() and SCM_RIGHTS. (There > are probably others, too.)
What can be done about this? Do any drivers protect themselves against the situation where after a fork() the parent and the child process can access the file descriptor without causing mayhem? What is the best way, or common practive to make driver really mpsafe?