title: Determine if QProcess is waiting for user input
body: <p>I am working on an application (developed in Qt 5.11, toolchain MSVS2017 64bit) which will, at some point, have to execute a .bat script. This .bat script will call certain program with appropriate cmd line arguments. Script and program will reside in same directory. This program may or may not require user to press Enter at the end. If program requires user to press Enter, program would never finish unless new line character is written in stdin.</p>
  
  <p>I want to check if program is waiting for user input before trying to write to its stdin, if possible using only Qt library.</p>
  
  <p>The .bat script would simply call program:</p>
  
  <pre><code>Program arg1 arg2 arg3...
  </code></pre>
  
  <p>From application, script would execute using QProcess: <br/>
   Added spleep after start of process</p>
  
  <pre><code>QProcess process;
  process.setWorkingDirectory("C:/path/to/script");
  process.start("cmd /C C:/path/to/script/script.bat");
  
  QThread::sleep(someTimeout);  // give enough time for process to finish
  
  if (/*somehow*/ process.isWaitingForInput())
      proces.write("\n");
  process.waitForFinished();
  process.readAllStandardOutput();
  process.readAllStandardInput();
  proces.exitCode();
  </code></pre>
  
  <p>I have found <a href="https://stackoverflow.com/questions/6911498/how-to-detect-when-a-process-thread-is-waiting-for-user-input">similar question</a> with answer pointing to <a href="http://msdn.microsoft.com/en-us/library/ms687022%28VS.85%29.aspx" rel="nofollow noreferrer">MSDN WaitForInputIdle</a>.</p>
  
  <p>In future port to Linux or Mac is possible and if it is possible I would like to avoid</p>
  
  <pre><code>#if defined(WIN32)
      WaitForInputIdle(...)
  #else
      PosixAlternative(...)
  #endif
  </code></pre>
  
  <p>Also, maybe of topic, but I am curious, is it possible to to execute .bat script from QProcess in a way that cmd/terminal window is shown along with std output?</p>