[PATCH 0/2] Return appropriate handle by _get_osfhandle() and GetStdHandle().
Tue Mar 23 14:27:29 GMT 2021
On Mar 23 22:51, Takashi Yano wrote:
> On Tue, 23 Mar 2021 14:32:39 +0100
> Corinna Vinschen wrote:
> > On Mar 23 21:52, Takashi Yano via Cygwin-patches wrote:
> > > On Tue, 23 Mar 2021 21:42:06 +0900
> > > Takashi Yano wrote:
> > > > On Tue, 23 Mar 2021 21:32:12 +0900
> > > > Takashi Yano wrote:
> > > > > I try to check run.exe behaviour and noticed that
> > > > > run cmd.exe
> > > > > and
> > > > > run cat.exe
> > > > > does not work with cygwin 3.0.7 and 3.2.0 (TEST) while these
> > > > > work in 3.1.7.
> > > >
> > > > In obove cases, cmd.exe and cat.exe is running in *hidden* console,
> > > > therefore nothing is shown. Right?
> > >
> > > In what situation are
> > > psi->cb = sizeof (STARTUPINFO);
> > > psi->hStdInput = GetStdHandle (STD_INPUT_HANDLE);
> > > psi->hStdOutput = GetStdHandle (STD_OUTPUT_HANDLE);
> > > psi->hStdError = GetStdHandle (STD_ERROR_HANDLE);
> > > these handles used?
> > Hmm, trying to make sense from the code, I'd say, these handles are used
> > by default, unless run.exe is already attached to a console. In the
> > latter case, it calls CreateFile( "CONIN$") etc. to attach the new
> > process to that console.
> "if (!bForceUsingPipes && bHaveConsole)"
> then handles are replaced by CreateFile("CONIN$", ...) etc.
> else replaced by pipe handle. If so, handles returned by
> GetStdHandle() are never used.
> Do I overlook something?
AFAICS, bForceUsingPipes is always FALSE. bHaveConsole is only TRUE if
run.exe is started from a console. If run.exe is started from the GUI
(which was the primary idea, IIRC), bHaveConsole is FALSE. So the
GetStdHandle() handles are used when started from thre GUI, isn't it?
More information about the Cygwin-patches