title: Replacing vector with array or static vector for a better approach
body: <p>My application runs particular number of processes(different executables) using createprocess(windows api) in parallel(using threads). User can refresh / close my application at any time. As of now, I am pushing the process handles into vector and whenever close request received, I am iterating the vector and terminating(using GetExitCodeProcess and TerminateProcess APIs) and closing(using CloseHandle API) the process handles. Also I am closing the handle of the process when it is completed. The problem with current model is, whenever process completed handle will be closed and when close request received again I will try to close it using vector(handle is not updated). To solve this, I have to update/remove the handle in/from the vector. To do this, need to maintain index.</p>
  <p>Since I know the number of process, I want to create a static vector and update it rather than pushing a local object to a vector. Can someone suggest a best approach.
  Below is the sample code.</p>
  <pre><code>//member object
  std::vector&lt;PROCESS_INFORMATION&gt; mProcessHandles;
  
  //this is a thread and will be called multiple times with different executable names in the application
  void method(std::string executable)
  {
      STARTUPINFO startInfo{};
      PROCESS_INFORMATION procInfo{};
      bool ret  = CreateProcess(NULL, executable, NULL, NULL, TRUE, CREATE_NO_WINDOW, NULL, NULL, &amp;startInfo, &amp;procInfo);
      mProcessInfo.push_back(procInfo);
      if(ret)
      {
          WaitForSingleObject(procInfo.hProcess, INFINITE);
          CloseHandle(procInfo.hProcess);
          procInfo.hProcess = NULL;
          CloseHandle(procInfo.hThread);
          procInfo.hThread = NULL;
      }
      return;
  }
  
  //this will be called when application close requested
  void forceKill()
  {
      for (auto &amp;processHandlesIt : mProcessHandles)
      {
          DWORD errorcode = 0;
          GetExitCodeProcess(processHandlesIt.hProcess, &amp;errorcode);
          if (errorcode == STILL_ACTIVE)
          {
              TerminateProcess(processHandlesIt.hProcess, errorcode);
          }
          CloseHandle(processHandlesIt.hProcess);
          processHandlesIt.hProcess = NULL;
          CloseHandle(processHandlesIt.hThread);
          processHandlesIt.hThread = NULL;
      }
  }
  </code></pre>