title: How to check if process is running on Red Hat Linux?
body: <p>I've been using a modified class I found to check if another instance of the same process is already running, the problem is that the method of checking for the process adds another instance of the same process.</p>
  
  <p>When my application starts, a new process ID is created and is visible with:</p>
  
  <pre><code>ps -A | grep "AppName"
  </code></pre>
  
  <p>With this I get a since entry returned, I then check for another instance of the application using:</p>
  
  <pre><code>QString strCMD = "ps -A | grep \"" + mcstrAppName + "\"";
  QProcess objProc;
  objProc.start("bash", QStringList() &lt;&lt; "-c" &lt;&lt; strCMD);
  
  if ( objProc.waitForStarted() != true || objProc.waitForFinished() != true ) {
      mcpobjApp-&gt;exit(cleanExit(-1, "Unable to determine if another instance is running!"));
      return;
  }
  </code></pre>
  
  <p>As soon as the 'start' method is called another instance of the same application appears in the process table, again, verified with:</p>
  
  <pre><code>ps -A | grep "AppName"
  </code></pre>
  
  <p>Two entries now appear each with a different PID.  I've also tried:</p>
  
  <pre><code>QString strOptions = "-A | grep \"" + mcstrAppName + "\"";
  QProcess objProc;
  objProc.start("ps", QStringList() &lt;&lt; strOptions);
  </code></pre>
  
  <p>The result is the same, two entries in process table.</p>
  
  <p>Is there a way to check the process table for another instance without adding an additional instance?</p>