title: bash shell script shows segmentation fault
body: <p>my shell script prints segmentation fault when it starts.</p>
  
  <p>watchdog.sh : <br></p>
  
  <pre><code>#!/bin/bash
  while true
  do
      processCnt=`ps ax | grep $1 | grep -v grep | grep -v watchdog | wc -l`
      if [ $processCnt -lt 1 ]; then
          $1 
      fi  
      sleep 2
  done
  </code></pre>
  
  <p>Script gets a program name as a parameter. <br>
  I also run this script 4 times with different parameter at the same time in run.sh.</p>
  
  <p>run.sh : <br></p>
  
  <pre><code>./watchdog.sh hqservicedemon &amp;
  ./watchdog.sh relayservicedemon &amp;
  ./watchdog.sh rtspservicedemon &amp;
  ./watchdog.sh httpcontrolservicedemon &amp;
  </code></pre>
  
  <p>When I run run.sh I get error:</p>
  
  <pre><code>./watchdog.sh: line xx:  7316 segmentation fault (core dumped)
  </code></pre>
  
  <p>After some tests it looks like OK when running just one watchdog.sh in run.sh.<br>
  What am I doing wrong in shell script? <br>
  Thank you for any advice. <br></p>
  
  <p>Edited:
  My demon has a problem, not a script. After fix demon, script works well.</p>