title: subprocess.Popen creationflags
body: <p>I want to spawn a subprocess, and it would be good if everything would happen in the background without opening a new Windows console.</p>
  
  <p>First I thought that something is wrong with my code, because it lead to errors while sending input to the subprocess.
  A Command like <strong>String</strong> e.g. generated an error </p>
  
  <blockquote>
    <p>Unknown Action: tring</p>
  </blockquote>
  
  <p>Meaning, from time to time the first character of the input sent to the subprocess via <code>stdin.write</code> was missing.</p>
  
  <p>That is the code:</p>
  
  <pre><code>    self.sp = subprocess.Popen(
          args,
          stdin=subprocess.PIPE,
          stdout=subprocess.PIPE,
          stderr=subprocess.PIPE
      )
  </code></pre>
  
  <p>Now I've tried the following, and everything works fine. The problem is the newly opened consoled. </p>
  
  <pre><code>    self.sp = subprocess.Popen(
          args,
          stdin=subprocess.PIPE,
          stdout=subprocess.PIPE,
          stderr=subprocess.PIPE,
          creationflags = subprocess.CREATE_NEW_CONSOLE
      )
  </code></pre>
  
  <p>Is there another way to achieve this without opening a new Windows console?</p>
  
  <p>&nbsp;</p>
  
  <hr>
  
  <p>Your links lead me to this description of the CREATE_NEW_WINDOW flag</p>
  
  <blockquote>
    <p>A process can also create a console by specifying the
    CREATE_NEW_CONSOLE flag in a call to CreateProcess. This method
    creates a new console that is accessible to the child process but not
    to the parent process. Separate consoles enable both parent and child
    processes to interact with the user without conflict. <strong><em>If this flag is
    not specified when a console process is created, both processes are
    attached to the same console, and there is no guarantee that the
    correct process will receive the input intended for it.</em></strong> Applications
    can prevent confusion by creating child processes that do not inherit
    handles of the input buffer, or by enabling only one child process at
    a time to inherit an input buffer handle while preventing the parent
    process from reading console input until the child has finished.</p>
  </blockquote>
  
  <p>If one could just create a new console without opening a window.</p>
  
  <hr>
  
  <p>This seems to have solved the problem</p>
  
  <pre><code>bufsize=1
  </code></pre>
  
  <p>Thank you.</p>