title: Timeout for grep in bash script
body: <p>I need to grep for a specific string in a specific time on an input:</p>
  
  <pre><code>trap "kill 0" EXIT SIGINT SIGTERM
  RESULT=$(adb logcat MyTag:V *:S | grep -m 1 "Hello World") &amp;
  sleep 10
  if [ "$RESULT" = "" ]; then
      echo "Timeout!"
  else
      echo "found"
  fi
  </code></pre>
  
  <p>with the trap the subshell gets killed correctly but i see that the grep does not work anymore now. <code>adb logcat</code> is the only process running in the subshell, when executing the script</p>