select() does not give timeout inside a bash script
<p>I have a problem that the select() does not give timeout when I run the program inside a bashscript file. This is my implementation:</p>

<pre><code>#include &lt;sys/select.h&gt;

bool checkKeyPressed()
{
  struct timeval tv;

  tv.tv_sec = 1;
  tv.tv_usec = 0;

  fd_set descriptor;
  const int input = 0;

  FD_ZERO(&amp;descriptor);
  FD_SET(input, &amp;descriptor);

  return select(1, &amp;descriptor, NULL, NULL, &amp;tv) &gt; 0;
}
</code></pre>

<p>// strace result after running the program directly (correct that there is a timeout)</p>

<pre><code>select(1, [0], NULL, NULL, {1, 0})      = 0 (Timeout)
</code></pre>

<p>// strace result to run the application inside a bash script file (no timeout)</p>

<pre><code>select(1, [0], NULL, NULL, {1, 0})      = 1 (in [0], left {0, 999996})
read(0, "", 1)                          = 0
</code></pre>

<p>How can I change the function to get it working with also running under the bashscript?</p>

<p>Thanks in advance.</p>
