in reply to fcntl on Windows

Since you are already using Tk, you may be interested in Tk::Fileevent and Tk::IO.

These give you a more generalized way of handling file and socket i/o in a gui event loop. (Basically placing a select() call for you in the gui event loop, you just supply a callback) Do read the CAVEATS and WARNINGS sections though.