title: Python Windows CMD mklink, stops working without error message
body: <p>I want to create symlinks for each file in a nested directory structure, where all symlinks will be put in one large flat folder, and have the following code by now:</p>
  
  <pre><code># loop over directory structure:
  # for all items in current directory,
  # if item is directory, recurse into it;
  # else it's a file, then create a symlink for it
  def makelinks(folder, targetfolder, cmdprocess = None):
      if not cmdprocess:
          cmdprocess = subprocess.Popen("cmd",
                                    stdin  = subprocess.PIPE,
                                    stdout = subprocess.PIPE,
                                    stderr = subprocess.PIPE)
      print(folder)
      for name in os.listdir(folder):
          fullname = os.path.join(folder, name)
          if os.path.isdir(fullname):
              makelinks(fullname, targetfolder, cmdprocess)
          else:
              makelink(fullname, targetfolder, cmdprocess)
  
  #for a given file, create one symlink in the target folder
  def makelink(fullname, targetfolder, cmdprocess):
      linkname = os.path.join(targetfolder, re.sub(r"[\/\\\:\*\?\"\&lt;\&gt;\|]", "-", fullname))
      if not os.path.exists(linkname):
          try:
              os.remove(linkname)
              print("Invalid symlink removed:", linkname)
          except: pass
      if not os.path.exists(linkname):
          cmdprocess.stdin.write("mklink " + linkname + " " + fullname + "\r\n")
  </code></pre>
  
  <p>So this is a top-down recursion where first the folder name is printed, then the subdirectories are processed. If I run this now over some folder, the whole thing just stops after 10 or so symbolic links. </p>
  
  <p>The program still seems to run but no new output is generated. It created 9 symlinks for some files in the <code># tag &amp; reencode</code> and the first three files in the <code>ChillOutMix</code> folder. The cmd.exe Window is still open and empty, and shows in its title bar that it is currently processing the mklink command for the third file in <code>ChillOutMix</code>.</p>
  
  <p>I tried to insert a <code>time.sleep(2)</code> after each <code>cmdprocess.stdin.write</code> in case Python is just too fast for the cmd process, but it doesn't help.</p>
  
  <p>Does anyone know what the problem might be?</p>