title: Initialize pid_t variable
body: <p>I have an error reported by Valgrind:</p>
  
  <pre><code>==5644== Conditional jump or move depends on uninitialised value(s)
  </code></pre>
  
  <p>This is happening for a variable of type <code>pid_t</code>.</p>
  
  <p>My code is the following:</p>
  
  <pre><code>GmpPipePlayer::GmpPipePlayer( IOBase *pIO, Referee *pBack, PieceColor pc, int size, const DataBoard *pBd, int handicap, const char *cmd_line, int bDebug )
      : GmpPlayer(pIO, pBack, pc, size, pBd, handicap, bDebug)
  {
      int down[2], up[2];
          pid_t _pid;  //here the var is declared
  
      pipe(down);   
      pipe(up);
  
  
      _pid = fork();
  
      if (_pid &lt; 0)
          exit(1);
  
  
      if (_pid == 0)
      {
          close(down[1]);
          close(up[0]);
  
          dup2(down[0], 0);
          dup2(up[1], 1);
  
          execl("/bin/sh", "sh", "-c", cmd_line, NULL);
  
          _exit(1);
      }
  
      close(down[0]);
      close(up[1]);
      _down = down[1];
      _up = up[0];
  
      _reader_thd = new Thread(reader_wrapper, this);
  }
  
  GmpPipePlayer::~GmpPipePlayer()
  {
      if (_pid &gt; 0)   //valgrind is reporting that the error is here!!
      {
          kill(_pid, SIGTERM);
          _pid = 0;
      }
  
      if (_up)
      {
          close(_up);
          _up = 0;
      }
  
      if (_down)
      {
          close(_down);
          _down = 0;
      }   
         delete _reader_thd
  }
  </code></pre>
  
  <p>So, I think the problem is the <code>_pid</code> is not initialized, how should initialize this variable?  I tried in this way:</p>
  
  <pre><code> pid_t _pid=0;
  </code></pre>
  
  <p>but this is still causing the same error. That piece of code is called many times during the process.</p>