title: How to AllocConsole + Stdout redirect under cygwin
body: <p>I have a complex >>cygwin&lt;&lt; windows application (aka. subsystem windows), and I want to add a debug console. I already tried the following variants, but none works for me.</p>
  
  <p>The console appears with changed title, but remains dead-black, no output shown.</p>
  
  <p>Variant 1)</p>
  
  <pre><code>ok = AllocConsole();
  if (ok) {
      h = GetStdHandle(STD_OUTPUT_HANDLE);
      fd = _open_osfhandle((intptr_t)h, O_TEXT);
      fp = _fdopen( fd, "w" );
      *stdout = *fp;
      setvbuf( stdout, NULL, _IONBF, 0 );
      fprintf(stdout, "Hello worldd\n");
      SetConsoleTitle("VM Debug");
  }
  </code></pre>
  
  <p>Variant 2)</p>
  
  <pre><code>freopen("conout$","w",stdout);
  fprintf(...
  </code></pre>
  
  <p>Variant 3)</p>
  
  <pre><code>freopen("/dev/conout","w",stdout);
  fprintf(...
  </code></pre>
  
  <p>This may have been answered already many times, but none of the solutions worked for me.</p>
  
  <p>Can anyone please help me? </p>
  
  <p>But please keep in mind: it MUST be a cygwin problem and I need a cywin solution, as I know that one or the other variant works under MSVC or BorlandC.
  Any answer helps, even one saying that cygwin is broken and there is no solution for me.</p>