title: Shell script hanging when calling cat
body: <p>I have a shell script which emails me errors encountered via crontasks which looks like the following:</p>
  
  <pre><code>exec &gt;&amp;-;
  
  output="$(cat)";
  
  shopt -s nocasematch
  
  if [[ "$output" == *"error"* || "$output" == *"warning"* ]]; then
      echo "$output" | mail -s "Error" my@email.com;
  fi
  
  exit 0;
  </code></pre>
  
  <p>My crontab looks like:</p>
  
  <pre><code>*/1 * * * * /opt/sh/email.sh /usr/bin/php /home/sites/website/app/console my:cli:command &gt;&gt; /var/log/cron.d/ my.cli.command/log 2&gt;&amp;1
  </code></pre>
  
  <p>The script works, but "cat" seem to hang:</p>
  
  <pre><code>root 23083 0.0 0.0 139752 1112 ? S Mar20 0:00 \_ CROND
  500 23091 0.0 0.0 106096 1016 ? Ss Mar20 0:00 | \_ /bin/sh -c /usr/bin/php /var/www/website/app/console my:cli:command 2&gt;&amp;1 | /usr/local/bin/email.sh
  500 23096 0.0 0.3 463528 27292 ? S Mar20 0:35 | \_ /usr/bin/php /var/www/website/app/console my:cli:command
  500 23097 0.0 0.0 106096 1048 ? S Mar20 0:00 | \_ /bin/bash /usr/local/bin/email.sh
  500 23101 0.0 0.0 100936 496 ? S Mar20 0:00 | \_ cat
  root 12167 0.0 0.0 139752 1276 ? S Mar22 0:00 \_ CROND
  500 12183 0.0 0.0 106096 1104 ? Ss Mar22 0:00 | \_ /bin/sh -c /usr/bin/php /var/www/website/app/console my:cli:command 2&gt;&amp;1 | /usr/local/bin/email.sh
  500 12185 0.0 0.4 463528 36612 ? S Mar22 0:32 | \_ /usr/bin/php /var/www/website/app/console my:cli:command
  500 12186 0.0 0.0 106096 1104 ? S Mar22 0:00 | \_ /bin/bash /usr/local/bin/email.sh
  500 12194 0.0 0.0 100936 516 ? S Mar22 0:00 | \_ cat
  root 1675 0.0 0.0 139752 1128 ? S Mar25 0:00 \_ CROND
  </code></pre>
  
  <p>Any ideas out there?</p>