Obtained from:	partly from anancient patch of mine via 1.1.5
Obtained from:	partly from anancient patch of mine via 1.1.5

Fix races for FIONREAD, TIOCSTI and TIOCSTAT.

jrobhoward/SCADAbase,jrobhoward/SCADAbase,jrobhoward/SCADAbase,jrobhoward/SCADAbase,jrobhoward/SCADAbase,jrobhoward/SCADAbase,jrobhoward/SCADAbase,jrobhoward/SCADAbase,jrobhoward/SCADAbase,jrobhoward/SCADAbase,jrobhoward/SCADAbase