[PATCH 0/2] Return appropriate handle by _get_osfhandle() and GetStdHandle().

Takashi Yano takashi.yano@nifty.ne.jp
Tue Mar 23 13:51:42 GMT 2021


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?

-- 
Takashi Yano <takashi.yano@nifty.ne.jp>


More information about the Cygwin-patches mailing list