title: How to interrupt io.read() in lua, which acts as "wait" function
body: <p>I am programming a user interface with Lua and Qt, and there is a process to draw a rectangle on a picture for the following process. Currently I use io.read() to wait for the rectangle is set by the user, who then presses "CTRL + D" to continue the program. I wonder if I could interrupt io.read() by codes, so that once the rectangle is set by user, the program will run automatically.
  To be more specific, here is a sample of what I will do.</p>
  
  <pre><code>function ui_select(x, y)
     if x1 == -1 then  -- First point of rectangle
        x1 = x
        y1 = y
     else     -- Second point of rectangle
        x2 = x
        y2 = y
        io.write(1)
     end
  end
  qt.connect(qt.QtLuaListener(ui.frame_2.canvas), 'sigMousePress(int, int, QByteArray, QByteArray, QByteArray)', ui_select)
  x1 = -1
  y1 = -1
  x2 = 0
  y2 = 0
  ui.frame_2.can_label.text = 'Draw a rectangle around the object you want to track, finish with "&lt;CTRL&gt; + D"'
  io.read()
  -- Do something
  </code></pre>
  
  <p>I wonder if I could interrupt io.read() in ui_select function, so once users draw the rectangle, it will automatically start processing.</p>
  
  <p>I can't just put the processing codes into ui_select function and delete io.read(), for this is the subprogram, and once there is no io.read() to wait for user's operation, it will just run from the beginning to the end without doing anything and goes back to the main program.</p>